[−][src]Struct cbor_data::CborBuilder
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]
F: FnMut(ArrayWriter<'_>) -> T,
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]
F: FnMut(DictWriter<'_>) -> T,
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]
F: FnMut(ArrayWriter<'_>),
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]
F: FnMut(DictWriter<'_>),
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
pub unsafe fn writer(&mut self) -> ArrayWriter<'_>
[src]
pub unsafe fn finish(self) -> Self::Output
[src]
pub fn encode_u64(self, value: u64) -> Self::Output
[src]
pub fn encode_i64(self, value: i64) -> Self::Output
[src]
pub fn encode_f64(self, value: f64) -> Self::Output
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,