pub struct Storage { /* private fields */ }Expand description
Thread-safe wrapper around a rusqlite::Connection.
Implementations§
Source§impl Storage
impl Storage
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open a connection at path and apply all migrations.
Sourcepub fn save_graph(&self, id: &str, graph: &IntentGraph) -> Result<()>
pub fn save_graph(&self, id: &str, graph: &IntentGraph) -> Result<()>
Persist a graph by the given id, replacing any previous version.
Sourcepub fn load_graph(&self, id: &str) -> Result<Option<IntentGraph>>
pub fn load_graph(&self, id: &str) -> Result<Option<IntentGraph>>
Fetch a graph by id.
Sourcepub fn list_graphs(&self) -> Result<Vec<String>>
pub fn list_graphs(&self) -> Result<Vec<String>>
List all stored graph ids, most-recently-updated first.
Sourcepub fn delete_graph(&self, id: &str) -> Result<bool>
pub fn delete_graph(&self, id: &str) -> Result<bool>
Delete a graph by id; returns true if a row was removed.
Sourcepub fn add_tag(&self, graph_id: &str, tag: &str) -> Result<bool>
pub fn add_tag(&self, graph_id: &str, tag: &str) -> Result<bool>
Attach a tag to a graph. Returns true if the tag was newly inserted,
false if the (graph_id, tag) pair was already present.
Sourcepub fn remove_tag(&self, graph_id: &str, tag: &str) -> Result<bool>
pub fn remove_tag(&self, graph_id: &str, tag: &str) -> Result<bool>
Remove a tag from a graph. Returns true if a row was deleted,
false if the tag was not present.
List the tags attached to a graph, in alphabetical order.
Sourcepub fn add_note(&self, graph_id: &str, body: &str) -> Result<i64>
pub fn add_note(&self, graph_id: &str, body: &str) -> Result<i64>
Append a free-form note to a graph. Returns the new note id.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Storage
impl RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnsafeUnpin for Storage
impl UnwindSafe for Storage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more