Node

Struct Node 

Source
pub struct Node<'d, 'w> { /* private fields */ }
Expand description

A Node is returned from Scope::node_named or Scope::node_auto, and allows for getting the id of the node for future reference via Node::id,

Importantly it also implements Attributes for setting attributes to override existing defaults for this specific node.

Implementations§

Source§

impl<'d, 'w> Node<'d, 'w>

Source

pub fn id(&self) -> NodeId

Returns a copy of the Node id, for later use with Scope::edge. Note that as the node definition will not finish writing until after this Node goes out of scope, you’ll need to save the id if you want to draw an edge to it later. This function is most usefull when the edge was automatically generated with Scope::node_auto:

use dot_writer::DotWriter;

let mut output_bytes = Vec::new();
{
    let mut writer = DotWriter::from(&mut output_bytes);
    writer.set_pretty_print(false);
    let mut digraph = writer.digraph();
    let a_id = {
        let mut sub_graph = digraph.subgraph();
        let a_id = sub_graph.node_auto().id();
        // sub_graph goes out of scope here to close bracket
        // but id is kept for later call
        a_id
    };
    digraph.edge(a_id, "b");
}
assert_eq!(
    std::str::from_utf8(&output_bytes).unwrap(),
    "digraph{subgraph{node_0;}node_0->b;}"
);

Trait Implementations§

Source§

impl<'d, 'w> Deref for Node<'d, 'w>

Source§

type Target = AttributesList<'d, 'w>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &AttributesList<'d, 'w>

Dereferences the value.
Source§

impl<'d, 'w> DerefMut for Node<'d, 'w>

Source§

fn deref_mut(&mut self) -> &mut AttributesList<'d, 'w>

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'d, 'w> Freeze for Node<'d, 'w>

§

impl<'d, 'w> !RefUnwindSafe for Node<'d, 'w>

§

impl<'d, 'w> !Send for Node<'d, 'w>

§

impl<'d, 'w> !Sync for Node<'d, 'w>

§

impl<'d, 'w> Unpin for Node<'d, 'w>

§

impl<'d, 'w> !UnwindSafe for Node<'d, 'w>

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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.