[][src]Struct jupiter::infograph::builder::DocBuilder

pub struct DocBuilder { /* fields omitted */ }

Provides a builder to generate a Doc.

A doc an internally have either a list or a map as its root node. Therefore either root_object_builder()or root_list_builder() has to be called the retrieve the appropriate builder after which build() must be called to create the resulting Doc.

Examples

Creating a list based Doc:

let mut builder = DocBuilder::new();
let mut list_builder = builder.root_list_builder();
list_builder.append_int(1);
list_builder.append_int(2);
list_builder.append_int(3);

let doc = builder.build();
assert_eq!(doc.root().at(1).as_int().unwrap(), 2);

Creating a map based Doc:

let mut builder = DocBuilder::new();
let mut obj_builder = builder.root_object_builder();
obj_builder.put_int("Test", 1);
obj_builder.put_int("Foo", 2);

let doc = builder.build();
assert_eq!(doc.root().query("Test").as_int().unwrap(), 1);
assert_eq!(doc.root().query("Foo").as_int().unwrap(), 2);

Implementations

impl DocBuilder[src]

pub fn new() -> Self[src]

Creates a new builder instance.

pub fn resolve(&mut self, symbol: impl AsRef<str>) -> Result<Symbol>[src]

Resolves the given name into a Symbol for repeated insertions.

Errors

If the internal symbol table overflows, an error is returned.

pub fn root_object_builder(&mut self) -> ObjectBuilder<'_>[src]

Makes the root node of the Doc a map and returns a builder for it.

Note that for each DocBuilder either root_object_builder or root_list_builder has to called exactly once.

pub fn root_list_builder(&mut self) -> ListBuilder<'_>[src]

Makes the root node of the Doc a list and returns a builder for it.

Note that for each DocBuilder either root_object_builder or root_list_builder has to called exactly once.

pub fn build(self) -> Doc[src]

Turns the builder into a Doc.

Auto Trait Implementations

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.