pub struct GraphOperations { /* private fields */ }Expand description
Graph operations for managing relations
Implementations§
Source§impl GraphOperations
impl GraphOperations
Sourcepub async fn create_relation(
&self,
from_id: &str,
to_id: &str,
relation_type: RelationType,
metadata: Option<String>,
) -> Result<()>
pub async fn create_relation( &self, from_id: &str, to_id: &str, relation_type: RelationType, metadata: Option<String>, ) -> Result<()>
Create a relation between two expertises
§Arguments
from_id- Source expertise IDto_id- Target expertise IDrelation_type- Type of relationmetadata- Optional JSON metadata
§Example
use niwa_core::{Database, RelationType};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let db = Database::open_default().await?;
db.graph().create_relation(
"rust-expert",
"error-handling",
RelationType::Uses,
None
).await?;
Ok(())
}Sourcepub async fn delete_relation(
&self,
from_id: &str,
to_id: &str,
relation_type: RelationType,
) -> Result<()>
pub async fn delete_relation( &self, from_id: &str, to_id: &str, relation_type: RelationType, ) -> Result<()>
Delete a relation
Sourcepub async fn get_outgoing(&self, from_id: &str) -> Result<Vec<Relation>>
pub async fn get_outgoing(&self, from_id: &str) -> Result<Vec<Relation>>
Get outgoing relations from an expertise
Sourcepub async fn get_incoming(&self, to_id: &str) -> Result<Vec<Relation>>
pub async fn get_incoming(&self, to_id: &str) -> Result<Vec<Relation>>
Get incoming relations to an expertise
Sourcepub async fn get_all_relations(&self, id: &str) -> Result<Vec<Relation>>
pub async fn get_all_relations(&self, id: &str) -> Result<Vec<Relation>>
Get all relations for an expertise (both incoming and outgoing)
Sourcepub async fn get_dependencies(&self, id: &str) -> Result<Vec<String>>
pub async fn get_dependencies(&self, id: &str) -> Result<Vec<String>>
Get dependencies (expertises that this expertise depends on)
Trait Implementations§
Source§impl Clone for GraphOperations
impl Clone for GraphOperations
Source§fn clone(&self) -> GraphOperations
fn clone(&self) -> GraphOperations
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for GraphOperations
impl !UnwindSafe for GraphOperations
impl Freeze for GraphOperations
impl Send for GraphOperations
impl Sync for GraphOperations
impl Unpin for GraphOperations
impl UnsafeUnpin for GraphOperations
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more