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
sourceimpl<'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
sourceimpl<'d, 'w> Deref for Node<'d, 'w>
impl<'d, 'w> Deref for Node<'d, 'w>
type Target = AttributesList<'d, 'w>
type Target = AttributesList<'d, 'w>
The resulting type after dereferencing.
sourcefn deref(&self) -> &AttributesList<'d, 'w>
fn deref(&self) -> &AttributesList<'d, 'w>
Dereferences the value.
Auto Trait Implementations
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>where
'w: 'd,
impl<'d, 'w> !UnwindSafe for Node<'d, 'w>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more