Struct dot_writer::DotWriter[][src]

pub struct DotWriter<'w> { /* fields omitted */ }
Expand description

The entry point struct for writing a DOT graph. See the examples on the index for how to use it. This struct must live for the livetime of writing the graph, and also outlive the Write struct it points to, because it’s Drop trait will finish writing graph.

Implementations

If set to true, then output will have additional whitespace including newlines and indentation to make the output more human friendly. If false then this will be left out and the output will be more compact. Defaults to true. For example disabled:

use dot_writer::DotWriter;

let mut bytes = Vec::new();
let mut writer = DotWriter::from(&mut bytes);
writer.set_pretty_print(false);
writer.graph().subgraph().cluster().subgraph();
println!("{}", std::str::from_utf8(&bytes).unwrap());

Gives you:

graph {subgraph {subgraph cluster_0 {subgraph {}}}}

While enabled:

use dot_writer::DotWriter;

let mut bytes = Vec::new();
let mut writer = DotWriter::from(&mut bytes);
// writer.set_pretty_print(false); defaults to true anyway
writer.graph().subgraph().cluster().subgraph();
println!("{}", std::str::from_utf8(&bytes).unwrap());

Gives you:

graph {
  subgraph {
    subgraph cluster_0 {
      subgraph {}
    }
  }
}

Start a new undirection graph. This uses the edge operator -- automatically, which means edges should be rendered without any arrowheads by default.

use dot_writer::DotWriter;

let mut bytes = Vec::new();
let mut writer = DotWriter::from(&mut bytes);
writer.set_pretty_print(false);
writer.graph().edge("a", "b");
assert_eq!(
    std::str::from_utf8(&bytes).unwrap(),
    "graph {a--b;}"
);

Start a new directed graph. This uses the edge operator -> automatically, which means edges should be redered with an arrow head pointing to the head (end) node.

use dot_writer::DotWriter;

let mut bytes = Vec::new();
let mut writer = DotWriter::from(&mut bytes);
writer.set_pretty_print(false);
writer.digraph().edge("a", "b");
assert_eq!(
    std::str::from_utf8(&bytes).unwrap(),
    "digraph {a->b;}"
);

Trait Implementations

This is the only constructor, which requires a Write to borrow and write the DOT output to. Defaults to pretty printing the output (see DotWriter::set_pretty_print).

Performs the conversion.

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

Performs the conversion.

Performs the conversion.

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.