use gpui::SharedString; use crate::context::{Context, ContextId, ContextKind}; pub struct ContextStore { context: Vec, next_context_id: ContextId, } impl ContextStore { pub fn new() -> Self { Self { context: Vec::new(), next_context_id: ContextId(0), } } pub fn context(&self) -> &Vec { &self.context } pub fn drain(&mut self) -> Vec { self.context.drain(..).collect() } pub fn clear(&mut self) { self.context.clear(); } pub fn insert_context( &mut self, kind: ContextKind, name: impl Into, text: impl Into, ) { self.context.push(Context { id: self.next_context_id.post_inc(), name: name.into(), kind, text: text.into(), }); } pub fn remove_context(&mut self, id: &ContextId) { self.context.retain(|context| context.id != *id); } }