[−][src]Struct cbor_data::ArrayBuilder
Builder for an array value, used by write_array()
.
Calling the finish()
method will return either the fully constructed
CBOR value (if this was the top-level array) or the builder of the array or dict into
which this array was placed.
If you want to recursively create a CBOR structure without statically known recursion limit
then you’ll want to take a look at the WriteToArray::write_array_rec()
method (the compiler would otherwise kindly inform you of a type expansion hitting the recursion
limit while instantiating your recursive function).
see trait Encoder
for usage examples
Implementations
impl<'a, T: 'a> ArrayBuilder<'a, T>
[src]
pub fn finish(self) -> T
[src]
Finish building this array and return to the outer context. In case of a
top-level array this returns the complete Cbor
value.
pub fn write_pos(&mut self, value: u64, tag: Option<u64>)
[src]
Write a unsigned value of up to 64 bits.
pub fn write_neg(&mut self, value: u64, tag: Option<u64>)
[src]
Write a negative value of up to 64 bits — the represented number is -1 - value
.
pub fn write_bytes(&mut self, value: &[u8], tag: Option<u64>)
[src]
Write the given slice as a definite size byte string.
pub fn write_str(&mut self, value: &str, tag: Option<u64>)
[src]
Write the given slice as a definite size string.
pub fn write_bool(&mut self, value: bool, tag: Option<u64>)
[src]
pub fn write_null(&mut self, tag: Option<u64>)
[src]
pub fn write_undefined(&mut self, tag: Option<u64>)
[src]
pub fn write_lit(&mut self, value: Literal, tag: Option<u64>)
[src]
Write custom literal value — RFC 7049 §2.3 is required reading.
pub fn write_array(self, tag: Option<u64>) -> ArrayBuilder<'a, Self>
[src]
Write a nested array that is then filled by the returned builder.
You can resume building this outer array by using the finish
()
method.
pub fn write_array_rec<F, U>(&mut self, tag: Option<u64>, f: F) -> U where
F: FnMut(ArrayWriter<'_>) -> U,
[src]
F: FnMut(ArrayWriter<'_>) -> U,
Write a nested array using the given closure that receives an array builder.
This method is very useful for recursively building a CBOR structure without statically known recursion limit, avoiding infinite type errors.
let mut cbor = CborBuilder::default().write_array(None); cbor.write_array_rec(None, |mut builder| { builder.write_pos(42, None); }); let cbor = cbor.finish();
pub fn write_dict(self, tag: Option<u64>) -> DictBuilder<'a, Self>
[src]
Write a nested dict that is then filled by the returned builder.
You can resume building this outer array by using the finish
()
method.
pub fn write_dict_rec<F, U>(&mut self, tag: Option<u64>, f: F) -> U where
F: FnMut(DictWriter<'_>) -> U,
[src]
F: FnMut(DictWriter<'_>) -> U,
Write a nested dict using the given closure that receives an dict builder.
This method is very useful for recursively building a CBOR structure without statically known recursion limit, avoiding infinite type errors.
let mut cbor = CborBuilder::default().write_array(None); cbor.write_dict_rec(None, |mut builder| { builder.write_pos("n", 42, None); }); let cbor = cbor.finish();
Trait Implementations
impl<'a, T: 'a> Encoder for ArrayBuilder<'a, T>
[src]
type Output = Self
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, T> !RefUnwindSafe for ArrayBuilder<'a, T>
[src]
impl<'a, T> !Send for ArrayBuilder<'a, T>
[src]
impl<'a, T> !Sync for ArrayBuilder<'a, T>
[src]
impl<'a, T> Unpin for ArrayBuilder<'a, T>
[src]
impl<'a, T> !UnwindSafe for ArrayBuilder<'a, T>
[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>,