Trait NetworkGraphWrite
pub trait NetworkGraphWrite {
type Error;
type Observed: EdgeObservable + Send;
type NodeId: Send;
// Required methods
fn add_node(&self, key: Self::NodeId);
fn remove_node(&self, key: &Self::NodeId);
fn add_edge(
&self,
src: &Self::NodeId,
dest: &Self::NodeId,
) -> Result<(), Self::Error>;
fn remove_edge(&self, src: &Self::NodeId, dest: &Self::NodeId);
fn upsert_edge<F>(&self, src: &Self::NodeId, dest: &Self::NodeId, f: F)
where F: FnOnce(&mut Self::Observed);
}Expand description
A trait for mutating the graph topology.
Provides methods to add/remove nodes and add edges.
Required Associated Types§
type Error
type Error
The error type returned by fallible write operations.
type Observed: EdgeObservable + Send
type Observed: EdgeObservable + Send
The concrete type of observations for peers.
Required Methods§
fn remove_node(&self, key: &Self::NodeId)
fn remove_node(&self, key: &Self::NodeId)
Removes a node and all its associated edges from the graph.
fn add_edge(
&self,
src: &Self::NodeId,
dest: &Self::NodeId,
) -> Result<(), Self::Error>
fn add_edge( &self, src: &Self::NodeId, dest: &Self::NodeId, ) -> Result<(), Self::Error>
Adds a directed edge between two existing nodes with default observations.
Returns an error if either node is not present in the graph.
fn remove_edge(&self, src: &Self::NodeId, dest: &Self::NodeId)
fn remove_edge(&self, src: &Self::NodeId, dest: &Self::NodeId)
Removes a directed edge between two nodes.
If the edge does not exist, this operation has no effect.
fn upsert_edge<F>(&self, src: &Self::NodeId, dest: &Self::NodeId, f: F)
fn upsert_edge<F>(&self, src: &Self::NodeId, dest: &Self::NodeId, f: F)
Updates an existing edge or inserts a new edge between two nodes.
If the nodes do not exist, they are inserted into the graph.
The provided closure f is applied to modify the edge’s observations.
If the edge already exists, its observations are updated.
If the edge does not exist, it is created and the closure is applied.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.