[][src]Struct cbor_data::CborBuilder

pub struct CborBuilder<'a>(_);

Builder for a single CBOR value.

Implementations

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

pub fn new() -> Self[src]

Create a builder that writes into its own fresh vector.

pub fn with_scratch_space(v: &'a mut Vec<u8>) -> Self[src]

Create a builder that clears the given vector and writes into it.

You can use this to reuse a scratch space across multiple values being built, e.g. by keeping the same vector in a thread-local variable.

pub fn write_pos(self, value: u64, tag: Option<u64>) -> CborOwned[src]

Write a unsigned value of up to 64 bits.

pub fn write_neg(self, value: u64, tag: Option<u64>) -> CborOwned[src]

Write a negative value of up to 64 bits — the represented number is -1 - value.

pub fn write_bytes(self, value: &[u8], tag: Option<u64>) -> CborOwned[src]

Write the given slice as a definite size byte string.

pub fn write_str(self, value: &str, tag: Option<u64>) -> CborOwned[src]

Write the given slice as a definite size string.

pub fn write_bool(self, value: bool, tag: Option<u64>) -> CborOwned[src]

pub fn write_null(self, tag: Option<u64>) -> CborOwned[src]

pub fn write_undefined(self, tag: Option<u64>) -> CborOwned[src]

pub fn write_lit(self, value: Literal, tag: Option<u64>) -> CborOwned[src]

Write custom literal value — RFC 7049 §2.3 is required reading.

pub fn write_array(self, tag: Option<u64>) -> ArrayBuilder<'a, CborOwned>[src]

Write an array that is then filled by the returned builder.

see trait Encoder for usage examples

pub fn write_array_rec<F, T>(self, tag: Option<u64>, f: F) -> (CborOwned, T) where
    F: FnMut(ArrayWriter<'_>) -> T, 
[src]

Write an array that is then filled by the provided closure using the passed builder.

see trait Encoder for usage examples

pub fn write_dict(self, tag: Option<u64>) -> DictBuilder<'a, CborOwned>[src]

Write a dict that is then filled by the returned builder.

see trait Encoder for usage examples

pub fn write_dict_rec<F, T>(self, tag: Option<u64>, f: F) -> (CborOwned, T) where
    F: FnMut(DictWriter<'_>) -> T, 
[src]

Write a dict that is then filled by the provided closure using the passed builder.

see trait Encoder for usage examples

pub fn encode_array<F>(self, f: F) -> CborOwned where
    F: FnMut(ArrayWriter<'_>), 
[src]

Write an array that is then filled by the provided closure using the passed builder.

see trait Encoder for usage examples

pub fn encode_dict<F>(self, f: F) -> CborOwned where
    F: FnMut(DictWriter<'_>), 
[src]

Write a dict that is then filled by the provided closure using the passed builder.

see trait Encoder for usage examples

Trait Implementations

impl Default for CborBuilder<'static>[src]

impl<'a> Encoder for CborBuilder<'a>[src]

type Output = CborOwned

Auto Trait Implementations

impl<'a> RefUnwindSafe for CborBuilder<'a>[src]

impl<'a> Send for CborBuilder<'a>[src]

impl<'a> Sync for CborBuilder<'a>[src]

impl<'a> Unpin for CborBuilder<'a>[src]

impl<'a> !UnwindSafe for CborBuilder<'a>[src]

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.