Struct cbor_data::DictWriter
source · [−]pub struct DictWriter<'a>(_);Expand description
Builder for a dict value, used by write_dict_rec().
see trait Encoder for usage examples
Implementations
sourceimpl<'a> DictWriter<'a>
impl<'a> DictWriter<'a>
pub fn max_definite(&self) -> Option<u64>
sourcepub fn set_max_definite_size(&mut self, size: Option<u64>)
pub fn set_max_definite_size(&mut self, size: Option<u64>)
Configure the limit above which indefinite size encoding will be used.
The default is 255, which is the largest size up to which definite size is at least as
compact as indefinite size. Set to 23 to avoid moving bytes around when finishing the array.
Set to None to always use indefinite size encoding.
sourcepub fn with_key(
&mut self,
key: &str,
f: impl FnOnce(SingleBuilder<'_, '_>) -> SingleResult
) -> &mut Self
pub fn with_key(
&mut self,
key: &str,
f: impl FnOnce(SingleBuilder<'_, '_>) -> SingleResult
) -> &mut Self
Add one key–value pair to the dict.
let cbor = CborBuilder::new().encode_dict(|builder| {
builder.with_key("the answer", |b| b.encode_u64(42));
});pub fn with_cbor_key(
&mut self,
k: impl FnOnce(SingleBuilder<'_, '_>) -> SingleResult,
v: impl FnOnce(SingleBuilder<'_, '_>) -> SingleResult
) -> &mut Self
pub fn try_write_pair<E>(
&mut self,
f: impl FnOnce(KeyBuilder<'_, '_>) -> Result<SingleResult, E>
) -> Result<&mut Self, E>
Auto Trait Implementations
impl<'a> RefUnwindSafe for DictWriter<'a>
impl<'a> Send for DictWriter<'a>
impl<'a> Sync for DictWriter<'a>
impl<'a> Unpin for DictWriter<'a>
impl<'a> !UnwindSafe for DictWriter<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more