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>
impl<'d, 'w> Node<'d, 'w>
Sourcepub fn id(&self) -> NodeId
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§
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> 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