TypedGraph

Struct TypedGraph 

Source
pub struct TypedGraph<NK, EK, S: SchemaExt<NK, EK>>
where NK: Key, EK: Key,
{ /* private fields */ }

Implementations§

Source§

impl<NK: Key, EK: Key, NT: GenericTypeIdentifier, ET: GenericTypeIdentifier> TypedGraph<NK, EK, GenericSchema<NT, ET>>

Source

pub fn assert_eq(&self, other: &Self) -> GenericResult<(), NK, EK, NT, ET>

Source§

impl<NK, EK, S> TypedGraph<NK, EK, S>
where NK: Key, EK: Key, S: SchemaExt<NK, EK>,

Source

pub fn new(schema: S) -> Self

Source

pub fn get_schema(&self) -> &S

Source

pub fn node_count(&self) -> usize

Source

pub fn edge_count(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn get_node_safe(&self, node_id: NK) -> Option<&S::N>

Source

pub fn get_node_safe_mut(&mut self, node_id: NK) -> Option<&mut S::N>

Source

pub fn get_edge_safe(&self, edge_id: EK) -> Option<&S::E>

Source

pub fn get_edge_safe_mut(&mut self, edge_id: EK) -> Option<&mut S::E>

Source

pub fn get_node(&self, node_id: NK) -> SchemaResult<&S::N, NK, EK, S>

Source

pub fn get_edge(&self, edge_id: EK) -> SchemaResult<&S::E, NK, EK, S>

Source

pub fn get_edge_full( &self, edge_id: EK, ) -> SchemaResult<EdgeRef<'_, NK, EK, S>, NK, EK, S>

Source

pub fn get_edge_full_mut( &mut self, edge_id: EK, ) -> SchemaResult<EdgeRefMut<'_, NK, EK, S>, NK, EK, S>

Source

pub fn get_node_mut( &mut self, node_id: NK, ) -> SchemaResult<&mut S::N, NK, EK, S>

Source

pub fn get_edge_mut( &mut self, edge_id: EK, ) -> SchemaResult<&mut S::E, NK, EK, S>

Source

pub fn get_node_downcast<'a: 'b, 'b, N: 'b>( &'a self, node_id: NK, ) -> SchemaResult<N, NK, EK, S>
where S::N: Downcast<'b, NK, EK, N, S>,

Source

pub fn get_node_downcast_mut<'a: 'b, 'b, N: 'b>( &'a mut self, node_id: NK, ) -> SchemaResult<N, NK, EK, S>
where S::N: DowncastMut<'b, NK, EK, N, S>,

Source

pub fn get_edge_downcast<'a: 'b, 'b, E: 'b>( &'a self, edge_id: EK, ) -> SchemaResult<E, NK, EK, S>
where S::E: Downcast<'b, NK, EK, E, S>,

Source

pub fn get_edge_downcast_mut<'a: 'b, 'b, E: 'b>( &'a mut self, edge_id: EK, ) -> SchemaResult<E, NK, EK, S>
where S::E: DowncastMut<'b, NK, EK, E, S>,

Source

pub fn has_node(&self, node_id: NK) -> bool

Source

pub fn has_edge(&self, edge_id: EK) -> bool

Source

pub fn move_edge_order( &mut self, source_id: EK, target_id: EK, insert_position: InsertPosition, ) -> SchemaResult<(), NK, EK, S>

Reorder the outgoing edge order by inserting the source edge and shifting all other edges

This will fail if both edges do not have the same source node

InsertPosition::Before the source edge will have the same index as the target edge currently has InsertPosition::After the source edge will be placed at target_idx + 1 instead

Source

pub fn add_node<N>(&mut self, node: N) -> SchemaResult<NK, NK, EK, S>
where N: Into<S::N>,

Source

pub fn update_node<N>(&mut self, node: N) -> SchemaResult<NK, NK, EK, S>
where N: Into<S::N>,

Add a node or update an existing one Updating a node is only allowed if all the connected edges allows for the new type

Source

pub fn can_add_edges( &self, source_node: &S::N, target_node: &S::N, weight: &S::E, ) -> SchemaResult<Result<(), DisAllowedEdge>, NK, EK, S>

Source

pub fn add_edge<E>( &mut self, source: NK, target: NK, edge: E, ) -> SchemaResult<EK, NK, EK, S>
where E: Into<S::E>,

Source

pub fn update_edge<E>( &mut self, source: NK, target: NK, edge: E, ) -> SchemaResult<EK, NK, EK, S>
where E: Into<S::E>,

Add or update the weight and enpoints of an edge The edge will preserve the order of endpoints that does not change

Source

pub fn remove_node(&mut self, node_id: NK) -> SchemaResult<S::N, NK, EK, S>

Remove a node and all edges to and from it

Source

pub fn remove_edge(&mut self, edge_id: EK) -> SchemaResult<S::E, NK, EK, S>

Remove an edge.

Source

pub fn get_incoming<'a>( &'a self, node_id: NK, ) -> SchemaResult<impl Iterator<Item = EdgeRef<'a, NK, EK, S>>, NK, EK, S>

Get all incoming edges

Source

pub fn get_outgoing<'a>( &'a self, node_id: NK, ) -> SchemaResult<impl Iterator<Item = EdgeRef<'a, NK, EK, S>>, NK, EK, S>

Source

pub fn get_incoming_and_outgoing<'a>( &'a self, node_id: NK, ) -> SchemaResult<impl Iterator<Item = EdgeRef<'a, NK, EK, S>>, NK, EK, S>

Source

pub fn get_outgoing_filter<'a, F>( &'a self, node_id: NK, filter: F, ) -> SchemaResult<impl Iterator<Item = EdgeRef<'a, NK, EK, S>>, NK, EK, S>
where F: Fn(&S::E) -> bool,

Source

pub fn get_incoming_filter<'a, F>( &'a self, node_id: NK, filter: F, ) -> SchemaResult<impl Iterator<Item = EdgeRef<'a, NK, EK, S>>, NK, EK, S>
where F: Fn(&S::E) -> bool,

Source

pub fn get_incoming_and_outgoing_filter<'a, F>( &'a self, node_id: NK, filter: F, ) -> SchemaResult<impl Iterator<Item = EdgeRef<'a, NK, EK, S>>, NK, EK, S>
where F: Fn(&S::E) -> bool,

Source

pub fn nodes(&self) -> impl Iterator<Item = &S::N> + '_

Source

pub fn edges(&self) -> impl Iterator<Item = &S::E> + '_

Source

pub fn edges_full<'a>( &'a self, ) -> impl Iterator<Item = EdgeRef<'a, NK, EK, S>> + 'a

Source

pub fn nodes_downcast<'a, T: 'a>(&'a self) -> impl Iterator<Item = T> + 'a
where S::N: Downcast<'a, NK, EK, T, S>,

Source

pub fn edges_downcast<'a, T: 'a>(&'a self) -> impl Iterator<Item = T> + 'a
where S::E: Downcast<'a, NK, EK, T, S>,

Source

pub fn node_ids(&self) -> impl Iterator<Item = NK> + '_

Source

pub fn edge_ids(&self) -> impl Iterator<Item = EK> + '_

Source

pub fn migrate<NS>( self, new_schema: NS, handler: &S::Handler, ) -> GenericTypedResult<TypedGraph<NK, EK, NS>, NK, EK>
where S: Migration<NK, EK, NS>, NS: SchemaExt<NK, EK> + Clone,

Apply a Migration to the current graph

Source

pub fn migrate_direct<NS>( self, ) -> GenericTypedResult<TypedGraph<NK, EK, NS>, NK, EK>
where S: DirectMigration<NK, EK, NS>, NS: SchemaExt<NK, EK>,

Migrate directly from one version to another

Source

pub fn update_schema<NS, NF, EF>( self, schema: NS, node_map: NF, edge_map: EF, ) -> SchemaResult<TypedGraph<NK, EK, NS>, NK, EK, NS>
where NS: SchemaExt<NK, EK>, NF: Fn(&S, &NS, S::N) -> SchemaResult<Option<NS::N>, NK, EK, NS>, EF: Fn(&S, &NS, S::E) -> SchemaResult<Option<NS::E>, NK, EK, NS>,

Convert the graph from one schema to another using two mapping functions The mapping functions are not allowed to change the id of any of the nodes only their data

Returning None from a mapping function will delete the node from the resulting graph

When mapping to a schema with lower bounds on the number of edges allowed from a node. Edges higher in the outgoing edge order will be removed

Trait Implementations§

Source§

impl<NK, EK, S: Clone + SchemaExt<NK, EK>> Clone for TypedGraph<NK, EK, S>
where NK: Key + Clone, EK: Key + Clone, S::N: Clone, S::E: Clone,

Source§

fn clone(&self) -> TypedGraph<NK, EK, S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<NK, EK, S: Debug + SchemaExt<NK, EK>> Debug for TypedGraph<NK, EK, S>
where NK: Key + Debug, EK: Key + Debug, S::N: Debug, S::E: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<NK, EK, S> Default for TypedGraph<NK, EK, S>
where NK: Key, EK: Key, S: SchemaExt<NK, EK> + Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, NK, EK, N, E, S> Deserialize<'de> for TypedGraph<NK, EK, S>
where NK: Key + Display + Deserialize<'de>, EK: Key + Display + Deserialize<'de>, N: NodeExt<NK> + Deserialize<'de>, E: EdgeExt<EK> + Deserialize<'de>, S: SchemaExt<NK, EK, N = N, E = E> + Deserialize<'de>,

Use the visitor to deserialize the TypedGraph

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<NK, EK, S> From<S> for TypedGraph<NK, EK, S>
where NK: Key, EK: Key, S: SchemaExt<NK, EK>,

Source§

fn from(value: S) -> Self

Converts to this type from the input type.
Source§

impl<NK, EK, N, E, S> Serialize for TypedGraph<NK, EK, S>
where NK: Key + Serialize, EK: Key + Serialize, N: Serialize + NodeExt<NK>, E: Serialize + EdgeExt<EK>, S: SchemaExt<NK, EK, N = N, E = E> + Serialize,

Source§

fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where Ser: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<NK, EK, S> Freeze for TypedGraph<NK, EK, S>
where S: Freeze,

§

impl<NK, EK, S> RefUnwindSafe for TypedGraph<NK, EK, S>
where S: RefUnwindSafe, NK: RefUnwindSafe, EK: RefUnwindSafe, <S as SchemaExt<NK, EK>>::N: RefUnwindSafe, <S as SchemaExt<NK, EK>>::E: RefUnwindSafe,

§

impl<NK, EK, S> Send for TypedGraph<NK, EK, S>
where S: Send, NK: Send, EK: Send, <S as SchemaExt<NK, EK>>::N: Send, <S as SchemaExt<NK, EK>>::E: Send,

§

impl<NK, EK, S> Sync for TypedGraph<NK, EK, S>
where S: Sync, NK: Sync, EK: Sync, <S as SchemaExt<NK, EK>>::N: Sync, <S as SchemaExt<NK, EK>>::E: Sync,

§

impl<NK, EK, S> Unpin for TypedGraph<NK, EK, S>
where S: Unpin, NK: Unpin, EK: Unpin, <S as SchemaExt<NK, EK>>::N: Unpin, <S as SchemaExt<NK, EK>>::E: Unpin,

§

impl<NK, EK, S> UnwindSafe for TypedGraph<NK, EK, S>
where S: UnwindSafe, NK: UnwindSafe, EK: UnwindSafe, <S as SchemaExt<NK, EK>>::N: UnwindSafe, <S as SchemaExt<NK, EK>>::E: UnwindSafe,

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> 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
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 = 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,