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

pub struct ListBuilder<'a> { /* fields omitted */ }

Builds an inner list within a Doc or another element.

A builder can either be obtained via DocBuilder::root_list_builder or using either ObjectBuilder::put_list - to place an inner list in another or via ListBuilder::append_list to add a list as child element to a list.

Implementations

impl<'a> ListBuilder<'a>[src]

pub fn append_int(&mut self, value: i64)[src]

Appends an integer value to the list being built.

Example

let mut builder = DocBuilder::new();
let mut list_builder = builder.root_list_builder();

list_builder.append_int(42);

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

pub fn append_string(&mut self, value: impl AsRef<str>)[src]

Appends a string to the list being built.

Example

let mut builder = DocBuilder::new();
let mut list_builder = builder.root_list_builder();

list_builder.append_string("Test");

let doc = builder.build();
assert_eq!(doc.root().at(0).as_str().unwrap(), "Test");

pub fn append_bool(&mut self, value: bool)[src]

Appends a bool value to the list being built.

Example

let mut builder = DocBuilder::new();
let mut list_builder = builder.root_list_builder();

list_builder.append_bool(true);

let doc = builder.build();
assert_eq!(doc.root().at(0).as_bool(), true);    

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

Appends a child-list to the list being built. Returns the builder used to populate the list.

Note that this will not join two lists but rather construct a list as child element and append further items to this child list.

Example

let mut builder = DocBuilder::new();
let mut list_builder = builder.root_list_builder();

let mut child_list_builder = list_builder.append_list();
child_list_builder.append_int(42);

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

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

Appends a child object to the list being built. Returns the builder used to populate the object.

Example

let mut builder = DocBuilder::new();
let mut list_builder = builder.root_list_builder();

let mut obj_builder = list_builder.append_object();
obj_builder.put_string("Foo", "Bar").unwrap();

let doc = builder.build();
assert_eq!(doc.root().len(), 1);    
assert_eq!(doc.root().at(0).query("Foo").as_str().unwrap(), "Bar");

Auto Trait Implementations

impl<'a> RefUnwindSafe for ListBuilder<'a>

impl<'a> Send for ListBuilder<'a>

impl<'a> Sync for ListBuilder<'a>

impl<'a> Unpin for ListBuilder<'a>

impl<'a> !UnwindSafe for ListBuilder<'a>

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.