Struct dot_writer::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

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

The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.