pub struct ObjectBuilder {
    pub object: Object,
    pub null: bool,
    pub skip: bool,
    pub root: Option<String>,
}

Fields§

§object: Object§null: bool§skip: bool§root: Option<String>

Implementations§

source§

impl ObjectBuilder

ObjectBuilder is used to produce JSON objects

source

pub fn new() -> ObjectBuilder

source

pub fn from_json(object: Value) -> Option<ObjectBuilder>

Initialize builder with initial value.

source

pub fn build<F>(builder: F) -> ObjectBuilder
where F: FnOnce(&mut ObjectBuilder),

Create new builder, pass it to closure as mutable ref and return.

source

pub fn null(&mut self)

It you call null, this object will be converted to null.

source

pub fn skip(&mut self)

It you call skip, this object will be skipped.

source

pub fn root(&mut self, root: &str)

source

pub fn has_root(&mut self) -> bool

source

pub fn unwrap(self) -> Value

Move out internal JSON value.

source§

impl ObjectBuilder

source

pub fn set<V: Serialize, N: Into<String>>(&mut self, name: N, value: V)

Set object’s name field with something that can be converted to Value value.

source

pub fn call<V: Serialize, N: Into<String>>(&mut self, name: N, value: V)

Stub for future use

source§

impl ObjectBuilder

source

pub fn set_json<N: Into<String>>(&mut self, name: N, value: Value)

Set object’s name field with raw Value value.

source

pub fn array<N: Into<String>, F>(&mut self, name: N, builder: F)
where F: FnOnce(&mut ArrayBuilder),

Build new array and set object’s name field with it.

source

pub fn object<N: Into<String>, F>(&mut self, name: N, builder: F)
where F: FnOnce(&mut ObjectBuilder),

Build new object and set object’s name field with it.

Trait Implementations§

source§

impl Serialize for ObjectBuilder

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Copy self to new JSON instance.

Auto Trait Implementations§

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>,

§

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>,

§

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.