pub struct Graph { /* private fields */ }Expand description
A graph: nodes joined by exec and data wires.
Nodes live in an ordered map rather than a vector because the canonical order is alphabetical by name. That order is what keeps diffs stable and spreads concurrent insertions by different people across the file instead of crowding them at the end.
Implementations§
Source§impl Graph
impl Graph
pub fn new(name: impl Into<String>) -> Self
pub fn name(&self) -> &str
pub fn insert_node(&mut self, node: Node)
pub fn node(&self, name: &str) -> Option<&Node>
Sourcepub fn insert_edge(&mut self, edge: Edge)
pub fn insert_edge(&mut self, edge: Edge)
A set rather than a vector: the same wire drawn twice, including by two people on separate branches, stays a single edge.
Sourcepub fn edges(&self) -> impl Iterator<Item = &Edge>
pub fn edges(&self) -> impl Iterator<Item = &Edge>
Edges in canonical order: exec first, then data, each sorted by its pin pair.
Sourcepub fn edges_from(&self, pin: &PinRef) -> impl Iterator<Item = &Edge>
pub fn edges_from(&self, pin: &PinRef) -> impl Iterator<Item = &Edge>
Wires leaving a pin.
The editor needs this for Blueprint’s rule that connecting a second wire to an exec output replaces the first, and the compiler needs it to check pin cardinality at all.
Sourcepub fn edges_into(&self, pin: &PinRef) -> impl Iterator<Item = &Edge>
pub fn edges_into(&self, pin: &PinRef) -> impl Iterator<Item = &Edge>
Wires arriving at a pin.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Graph
impl<'de> Deserialize<'de> for Graph
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Graph
Auto Trait Implementations§
impl Freeze for Graph
impl RefUnwindSafe for Graph
impl Send for Graph
impl Sync for Graph
impl Unpin for Graph
impl UnsafeUnpin for Graph
impl UnwindSafe for Graph
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