[][src]Struct id_tree_layout::layouter::Layouter

pub struct Layouter<'a, 'b, 'c, T> where
    T: Visualize
{ /* fields omitted */ }

The Layouter type provides a simple builder mechanism with a fluent API.

Implementations

impl<'a, 'b, 'c, T> Layouter<'a, 'b, 'c, T> where
    T: Visualize
[src]

pub fn new(tree: &'a Tree<T>) -> Self[src]

Creates a new Layouter with the required tree.

use id_tree_layout::{Layouter, Visualize};
use id_tree::{Tree, TreeBuilder};

struct MyNodeData(i32);

impl Visualize for MyNodeData {
    fn visualize(&self) -> std::string::String { self.0.to_string() }
    fn emphasize(&self) -> bool { false }
}


let tree: Tree<MyNodeData> = TreeBuilder::new().build();
let layouter = Layouter::new(&tree);

pub fn with_file_path(self, path: &'c Path) -> Self[src]

Sets the path of the output file on the layouter.

use id_tree_layout::{Layouter, Visualize};
use id_tree::{Tree, TreeBuilder};
use std::path::Path;

struct MyNodeData(i32);

impl Visualize for MyNodeData {
    fn visualize(&self) -> std::string::String { self.0.to_string() }
    fn emphasize(&self) -> bool { false }
}


let tree: Tree<MyNodeData> = TreeBuilder::new().build();
let layouter = Layouter::new(&tree)
    .with_file_path(Path::new("test.svg"));

pub fn with_drawer(self, drawer: &'b dyn Drawer) -> Self[src]

Sets a different drawer when you don't want to use the default svg-drawer. If this method is not called the crate's own svg-drawer is used.

use id_tree_layout::{Drawer, Layouter, PlacedTreeItem, Visualize};
use id_tree_layout::drawer::Result;
use id_tree::{Tree, TreeBuilder};
use std::path::Path;

struct NilDrawer;
impl Drawer for NilDrawer {
    fn draw(&self, _file_name: &Path, _embedding: &[PlacedTreeItem]) -> Result {
        Ok(())
    }
}

struct MyNodeData(i32);

impl Visualize for MyNodeData {
    fn visualize(&self) -> std::string::String { self.0.to_string() }
    fn emphasize(&self) -> bool { false }
}


let tree: Tree<MyNodeData> = TreeBuilder::new().build();
let drawer = NilDrawer;
let layouter = Layouter::new(&tree)
    .with_drawer(&drawer)
    .with_file_path(Path::new("test.svg"));

pub fn write(&self) -> Result[src]

When the layouter instance is fully configured this method invokes the necessary embedding functionality and uses the drawer which writes the result to the output file in its own output format.

use id_tree_layout::{Layouter, Visualize};
use id_tree::{Tree, TreeBuilder};
use std::path::Path;

struct MyNodeData(i32);

impl Visualize for MyNodeData {
    fn visualize(&self) -> std::string::String { self.0.to_string() }
    fn emphasize(&self) -> bool { false }
}


let tree: Tree<MyNodeData> = TreeBuilder::new().build();
Layouter::new(&tree)
    .with_file_path(Path::new("test.svg"))
    .write().expect("Failed writing layout")

Auto Trait Implementations

impl<'a, 'b, 'c, T> !RefUnwindSafe for Layouter<'a, 'b, 'c, T>

impl<'a, 'b, 'c, T> !Send for Layouter<'a, 'b, 'c, T>

impl<'a, 'b, 'c, T> !Sync for Layouter<'a, 'b, 'c, T>

impl<'a, 'b, 'c, T> Unpin for Layouter<'a, 'b, 'c, T>

impl<'a, 'b, 'c, T> !UnwindSafe for Layouter<'a, 'b, 'c, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.