Skip to main content

Storage

Struct Storage 

Source
pub struct Storage { /* private fields */ }
Expand description

Thread-safe wrapper around a rusqlite::Connection.

Implementations§

Source§

impl Storage

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open a connection at path and apply all migrations.

Source

pub fn in_memory() -> Result<Self>

Open an in-memory database. Useful for tests.

Source

pub fn migrate(&self) -> Result<()>

Apply all pending migrations to the open connection.

Source

pub fn save_graph(&self, id: &str, graph: &IntentGraph) -> Result<()>

Persist a graph by the given id, replacing any previous version.

Source

pub fn load_graph(&self, id: &str) -> Result<Option<IntentGraph>>

Fetch a graph by id.

Source

pub fn list_graphs(&self) -> Result<Vec<String>>

List all stored graph ids, most-recently-updated first.

Source

pub fn delete_graph(&self, id: &str) -> Result<bool>

Delete a graph by id; returns true if a row was removed.

Source

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.

Source

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.

Source

pub fn list_tags(&self, graph_id: &str) -> Result<Vec<String>>

List the tags attached to a graph, in alphabetical order.

Source

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.

Source

pub fn list_notes(&self, graph_id: &str) -> Result<Vec<Note>>

List notes attached to a graph, oldest first.

Source

pub fn delete_note(&self, graph_id: &str, note_id: i64) -> Result<bool>

Delete a note by id, scoped to a specific graph. Returns true if a row was deleted, false otherwise (note did not exist for that graph).

Trait Implementations§

Source§

impl Clone for Storage

Source§

fn clone(&self) -> Storage

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Storage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.