Skip to main content

Store

Struct Store 

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

A Roteiro graph store backed by a single SQLite database.

Implementations§

Source§

impl Store

Source

pub fn open(path: &Path) -> Result<Self, StoreError>

Open (creating if absent) a store at path and apply pending migrations.

§Errors

Returns StoreError::Sqlite if the database cannot be opened or a migration fails.

Source

pub fn open_in_memory() -> Result<Self, StoreError>

Open an in-memory store (tests, previews).

§Errors

Returns StoreError::Sqlite if a migration fails.

Source

pub fn schema_version(&self) -> Result<u32, StoreError>

The schema version this store has been migrated to.

§Errors

Returns StoreError::Sqlite on query failure.

Source

pub fn node_count(&self) -> Result<u64, StoreError>

Number of nodes currently in the store.

§Errors

Returns StoreError::Sqlite on query failure.

Source

pub fn edge_count(&self) -> Result<u64, StoreError>

Number of edges currently in the store.

§Errors

Returns StoreError::Sqlite on query failure.

Source

pub fn upsert_node(&self, node: &Node) -> Result<(), StoreError>

Insert or update a node, keyed by its natural Node::key.

§Errors

Returns StoreError::Json if meta cannot be serialized, or StoreError::Sqlite on write failure.

Source

pub fn insert_edge(&self, edge: &Edge) -> Result<(), StoreError>

Insert an edge. Both endpoints must already resolve to nodes.

§Errors

Returns StoreError::InvalidEdge if the provenance/confidence invariant is violated, StoreError::UnknownNode if an endpoint key is absent, or StoreError::Sqlite on write failure.

Source

pub fn apply_factset(&mut self, facts: &FactSet) -> Result<(), StoreError>

Apply a fact set atomically: all nodes are upserted, then all edges are inserted, in a single transaction. On any error nothing is committed.

§Errors

Returns the first error encountered (see Store::upsert_node and Store::insert_edge); the transaction is rolled back.

Source

pub fn get_node(&self, key: &str) -> Result<Option<Node>, StoreError>

Fetch a node by its natural key.

§Errors

Returns StoreError::Sqlite, StoreError::Json, or StoreError::Corrupt if a stored value cannot be decoded.

Source

pub fn nodes_by_kind(&self, kind: &NodeKind) -> Result<Vec<Node>, StoreError>

All nodes of a given kind.

§Errors

Returns StoreError::Sqlite, StoreError::Json, or StoreError::Corrupt on decode failure.

Source

pub fn edges_from(&self, key: &str) -> Result<Vec<Edge>, StoreError>

Edges whose source is the node with the given key.

§Errors

Returns StoreError::Sqlite or StoreError::Corrupt on failure.

Source

pub fn edges_to(&self, key: &str) -> Result<Vec<Edge>, StoreError>

Edges whose destination is the node with the given key.

§Errors

Returns StoreError::Sqlite or StoreError::Corrupt on failure.

Source

pub fn edges_by_provenance( &self, provenance: Provenance, ) -> Result<Vec<Edge>, StoreError>

All edges with the given provenance.

§Errors

Returns StoreError::Sqlite or StoreError::Corrupt on failure.

Source

pub fn neighbors( &self, key: &str, dir: Direction, ) -> Result<Vec<Node>, StoreError>

Neighbouring nodes reachable from key in the given direction. Returns an empty vector if the node does not exist.

§Errors

Returns StoreError::Sqlite, StoreError::Json, or StoreError::Corrupt on failure.

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl !Sync for Store

§

impl !UnwindSafe for Store

§

impl Send for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.