Struct TreeBuilder

Source
pub struct TreeBuilder<N, W> { /* private fields */ }
Expand description

Serializes a tree data structure in a depth first manner.

Implementations§

Source§

impl<N, W> TreeBuilder<N, W>

Source

pub fn new(writer: W) -> Self

Source

pub fn write_node( &mut self, value: &N::Value, num_children: usize, ) -> Result<()>
where N: Node, W: Write,

Adds a node to the tree.

§Parameters
  • value: Value associated with the node
  • num_children: This node will be the parent node of the last num_children nodes written which do not have a parent yet.
Source

pub fn finish(self) -> Result<W>
where W: Write,

Call this once every node has been written. Flushes the output and returns the inner writer in case you want to use it for something else.

Auto Trait Implementations§

§

impl<N, W> Freeze for TreeBuilder<N, W>
where W: Freeze,

§

impl<N, W> RefUnwindSafe for TreeBuilder<N, W>

§

impl<N, W> Send for TreeBuilder<N, W>
where W: Send, N: Send,

§

impl<N, W> Sync for TreeBuilder<N, W>
where W: Sync, N: Sync,

§

impl<N, W> Unpin for TreeBuilder<N, W>
where W: Unpin, N: Unpin,

§

impl<N, W> UnwindSafe for TreeBuilder<N, W>
where W: UnwindSafe, N: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.