pub trait Datastore {
Show 21 methods
fn create_vertex(&self, vertex: &Vertex) -> Result<bool>;
fn get_vertices(&self, q: VertexQuery) -> Result<Vec<Vertex>>;
fn delete_vertices(&self, q: VertexQuery) -> Result<()>;
fn get_vertex_count(&self) -> Result<u64>;
fn create_edge(&self, key: &EdgeKey) -> Result<bool>;
fn get_edges(&self, q: EdgeQuery) -> Result<Vec<Edge>>;
fn delete_edges(&self, q: EdgeQuery) -> Result<()>;
fn get_edge_count(
&self,
id: Uuid,
t: Option<&Identifier>,
direction: EdgeDirection
) -> Result<u64>;
fn get_vertex_properties(
&self,
q: VertexPropertyQuery
) -> Result<Vec<VertexProperty>>;
fn get_all_vertex_properties(
&self,
q: VertexQuery
) -> Result<Vec<VertexProperties>>;
fn set_vertex_properties(
&self,
q: VertexPropertyQuery,
value: Value
) -> Result<()>;
fn delete_vertex_properties(&self, q: VertexPropertyQuery) -> Result<()>;
fn get_edge_properties(
&self,
q: EdgePropertyQuery
) -> Result<Vec<EdgeProperty>>;
fn get_all_edge_properties(
&self,
q: EdgeQuery
) -> Result<Vec<EdgeProperties>>;
fn set_edge_properties(
&self,
q: EdgePropertyQuery,
value: Value
) -> Result<()>;
fn delete_edge_properties(&self, q: EdgePropertyQuery) -> Result<()>;
fn index_property(&self, name: Identifier) -> Result<()>;
fn sync(&self) -> Result<()> { ... }
fn transaction(&self) -> Result<Self>
where
Self: Sized,
{ ... }
fn create_vertex_from_type(&self, t: Identifier) -> Result<Uuid> { ... }
fn bulk_insert(&self, items: Vec<BulkInsertItem>) -> Result<()> { ... }
}Expand description
Specifies a datastore implementation.
Note that this trait and its members purposefully do not employ any generic arguments. While that would improve ergonomics, it would remove object safety, which we need for plugins.
Errors
All methods may return an error if something unexpected happens - e.g. if there was a problem connecting to the underlying database.
Required Methods§
sourcefn create_vertex(&self, vertex: &Vertex) -> Result<bool>
fn create_vertex(&self, vertex: &Vertex) -> Result<bool>
Creates a new vertex. Returns whether the vertex was successfully created - if this is false, it’s because a vertex with the same UUID already exists.
Arguments
vertex: The vertex to create.
sourcefn get_vertices(&self, q: VertexQuery) -> Result<Vec<Vertex>>
fn get_vertices(&self, q: VertexQuery) -> Result<Vec<Vertex>>
sourcefn delete_vertices(&self, q: VertexQuery) -> Result<()>
fn delete_vertices(&self, q: VertexQuery) -> Result<()>
sourcefn get_vertex_count(&self) -> Result<u64>
fn get_vertex_count(&self) -> Result<u64>
Gets the number of vertices in the datastore.
sourcefn create_edge(&self, key: &EdgeKey) -> Result<bool>
fn create_edge(&self, key: &EdgeKey) -> Result<bool>
Creates a new edge. If the edge already exists, this will update it with a new update datetime. Returns whether the edge was successfully created - if this is false, it’s because one of the specified vertices is missing.
Arguments
key: The edge to create.
sourcefn delete_edges(&self, q: EdgeQuery) -> Result<()>
fn delete_edges(&self, q: EdgeQuery) -> Result<()>
sourcefn get_edge_count(
&self,
id: Uuid,
t: Option<&Identifier>,
direction: EdgeDirection
) -> Result<u64>
fn get_edge_count(
&self,
id: Uuid,
t: Option<&Identifier>,
direction: EdgeDirection
) -> Result<u64>
Gets the number of edges associated with a vertex.
Arguments
id: The id of the vertex.t: Only get the count for a specified edge type.direction: The direction of edges to get.
sourcefn get_vertex_properties(
&self,
q: VertexPropertyQuery
) -> Result<Vec<VertexProperty>>
fn get_vertex_properties(
&self,
q: VertexPropertyQuery
) -> Result<Vec<VertexProperty>>
sourcefn get_all_vertex_properties(
&self,
q: VertexQuery
) -> Result<Vec<VertexProperties>>
fn get_all_vertex_properties(
&self,
q: VertexQuery
) -> Result<Vec<VertexProperties>>
sourcefn set_vertex_properties(
&self,
q: VertexPropertyQuery,
value: Value
) -> Result<()>
fn set_vertex_properties(
&self,
q: VertexPropertyQuery,
value: Value
) -> Result<()>
sourcefn delete_vertex_properties(&self, q: VertexPropertyQuery) -> Result<()>
fn delete_vertex_properties(&self, q: VertexPropertyQuery) -> Result<()>
sourcefn get_edge_properties(&self, q: EdgePropertyQuery) -> Result<Vec<EdgeProperty>>
fn get_edge_properties(&self, q: EdgePropertyQuery) -> Result<Vec<EdgeProperty>>
sourcefn get_all_edge_properties(&self, q: EdgeQuery) -> Result<Vec<EdgeProperties>>
fn get_all_edge_properties(&self, q: EdgeQuery) -> Result<Vec<EdgeProperties>>
sourcefn set_edge_properties(&self, q: EdgePropertyQuery, value: Value) -> Result<()>
fn set_edge_properties(&self, q: EdgePropertyQuery, value: Value) -> Result<()>
sourcefn delete_edge_properties(&self, q: EdgePropertyQuery) -> Result<()>
fn delete_edge_properties(&self, q: EdgePropertyQuery) -> Result<()>
fn index_property(&self, name: Identifier) -> Result<()>
Provided Methods§
sourcefn sync(&self) -> Result<()>
fn sync(&self) -> Result<()>
Syncs persisted content. Depending on the datastore implementation, this has different meanings - including potentially being a no-op.
sourcefn transaction(&self) -> Result<Self>where
Self: Sized,
fn transaction(&self) -> Result<Self>where
Self: Sized,
Creates a new transaction. Some datastore implementations do not support transactional updates, in which case this will return an error.
sourcefn create_vertex_from_type(&self, t: Identifier) -> Result<Uuid>
fn create_vertex_from_type(&self, t: Identifier) -> Result<Uuid>
Creates a new vertex with just a type specification. As opposed to
create_vertex, this is used when you do not want to manually specify
the vertex’s UUID. Returns the new vertex’s UUID.
Arguments
t: The type of the vertex to create.