Skip to main content

StablePayloadGraph

Struct StablePayloadGraph 

Source
pub struct StablePayloadGraph<NodePayload, EdgePayload> { /* private fields */ }
Expand description

A mutable directed payload graph with generation-checked stable keys.

Implementations§

Source§

impl<NodePayload, EdgePayload> StablePayloadGraph<NodePayload, EdgePayload>

Source

pub const fn new() -> Self

Source

pub fn with_capacity(nodes: usize, edges: usize) -> Self

Source

pub fn add_node(&mut self, payload: NodePayload) -> Result<StableNodeKey>

Adds a payload and returns a key that detects later slot reuse.

§Errors

Returns an error when the stable index space is exhausted.

Source

pub fn add_edge( &mut self, source: StableNodeKey, target: StableNodeKey, payload: EdgePayload, ) -> Result<StableEdgeKey>

Adds a directed edge between two live stable node keys.

§Errors

Returns an error for stale endpoints or exhausted stable indices.

Source

pub fn node(&self, key: StableNodeKey) -> Option<&NodePayload>

Source

pub fn node_mut(&mut self, key: StableNodeKey) -> Option<&mut NodePayload>

Source

pub fn edge(&self, key: StableEdgeKey) -> Option<&EdgePayload>

Source

pub fn edge_mut(&mut self, key: StableEdgeKey) -> Option<&mut EdgePayload>

Source

pub fn edge_endpoints( &self, key: StableEdgeKey, ) -> Option<EdgeEndpoints<StableNodeKey>>

Source

pub fn nodes(&self) -> impl Iterator<Item = (StableNodeKey, &NodePayload)>

Source

pub fn edges(&self) -> impl Iterator<Item = (StableEdgeKey, &EdgePayload)>

Source

pub fn outgoing_edges( &self, node: StableNodeKey, ) -> impl Iterator<Item = StableEdgeKey> + '_

Source

pub fn incoming_edges( &self, node: StableNodeKey, ) -> impl Iterator<Item = StableEdgeKey> + '_

Source

pub const fn node_count(&self) -> usize

Source

pub const fn edge_count(&self) -> usize

Source

pub const fn is_empty(&self) -> bool

Source§

impl<NodePayload, EdgePayload> StablePayloadGraph<NodePayload, EdgePayload>

Source

pub fn freeze(self) -> Result<FrozenPayloadGraph<NodePayload, EdgePayload>>

Compacts live slots into an immutable CSR-backed payload graph.

§Errors

Returns an error if compact index capacity is exhausted.

Source§

impl<NodePayload, EdgePayload> StablePayloadGraph<NodePayload, EdgePayload>

Source

pub fn map_payloads<MappedNode, MappedEdge, NodeMap, EdgeMap>( self, map_node: NodeMap, map_edge: EdgeMap, ) -> StablePayloadGraph<MappedNode, MappedEdge>
where NodeMap: FnMut(NodePayload) -> MappedNode, EdgeMap: FnMut(EdgePayload) -> MappedEdge,

Source§

impl<NodePayload, EdgePayload> StablePayloadGraph<NodePayload, EdgePayload>

Source

pub fn remove_edge(&mut self, key: StableEdgeKey) -> Option<EdgePayload>

Source

pub fn remove_node(&mut self, key: StableNodeKey) -> Option<NodePayload>

Source

pub fn set_edge_endpoints( &mut self, key: StableEdgeKey, source: StableNodeKey, target: StableNodeKey, ) -> Result<bool>

Moves a live edge without changing its stable key or payload.

§Errors

Returns an error when either new endpoint key is stale.

Trait Implementations§

Source§

impl<NodePayload: Clone, EdgePayload: Clone> Clone for StablePayloadGraph<NodePayload, EdgePayload>

Source§

fn clone(&self) -> StablePayloadGraph<NodePayload, EdgePayload>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<NodePayload: Debug, EdgePayload: Debug> Debug for StablePayloadGraph<NodePayload, EdgePayload>

Source§

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

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

impl<NodePayload, EdgePayload> Default for StablePayloadGraph<NodePayload, EdgePayload>

Source§

fn default() -> Self

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

impl<NodePayload, EdgePayload> GraphView for StablePayloadGraph<NodePayload, EdgePayload>

Source§

type Node = StableNodeKey

Source§

type Edge = StableEdgeKey

Source§

fn node_count(&self) -> usize

Source§

fn edge_count(&self) -> usize

Source§

fn contains_node(&self, node: Self::Node) -> bool

Source§

fn contains_edge(&self, edge: Self::Edge) -> bool

Source§

fn node_indices(&self) -> impl Iterator<Item = Self::Node> + '_

Source§

fn edge_indices(&self) -> impl Iterator<Item = Self::Edge> + '_

Source§

fn edge_endpoints(&self, edge: Self::Edge) -> Option<EdgeEndpoints<Self::Node>>

Source§

fn outgoing_edges( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Edge> + '_

Source§

fn incoming_edges( &self, node: Self::Node, ) -> impl Iterator<Item = Self::Edge> + '_

Source§

fn edge_references( &self, ) -> impl Iterator<Item = (Self::Edge, EdgeEndpoints<Self::Node>)> + '_

Source§

impl<NodePayload, EdgePayload> IndexGraphView for StablePayloadGraph<NodePayload, EdgePayload>

Source§

fn node_bound(&self) -> usize

Source§

fn edge_bound(&self) -> usize

Source§

fn node_slot(node: Self::Node) -> usize

Source§

fn edge_slot(edge: Self::Edge) -> usize

Auto Trait Implementations§

§

impl<NodePayload, EdgePayload> Freeze for StablePayloadGraph<NodePayload, EdgePayload>

§

impl<NodePayload, EdgePayload> RefUnwindSafe for StablePayloadGraph<NodePayload, EdgePayload>
where NodePayload: RefUnwindSafe, EdgePayload: RefUnwindSafe,

§

impl<NodePayload, EdgePayload> Send for StablePayloadGraph<NodePayload, EdgePayload>
where NodePayload: Send, EdgePayload: Send,

§

impl<NodePayload, EdgePayload> Sync for StablePayloadGraph<NodePayload, EdgePayload>
where NodePayload: Sync, EdgePayload: Sync,

§

impl<NodePayload, EdgePayload> Unpin for StablePayloadGraph<NodePayload, EdgePayload>
where NodePayload: Unpin, EdgePayload: Unpin,

§

impl<NodePayload, EdgePayload> UnsafeUnpin for StablePayloadGraph<NodePayload, EdgePayload>

§

impl<NodePayload, EdgePayload> UnwindSafe for StablePayloadGraph<NodePayload, EdgePayload>
where NodePayload: UnwindSafe, EdgePayload: 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> 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.