pub struct ArrayEncoder<'a> { /* private fields */ }alloc only.Expand description
Builder for writing array elements into a canonical CBOR stream.
Implementations§
Source§impl ArrayEncoder<'_>
impl ArrayEncoder<'_>
Sourcepub fn bool(&mut self, v: bool) -> Result<(), CborError>
pub fn bool(&mut self, v: bool) -> Result<(), CborError>
Encode a CBOR boolean.
§Errors
Returns an error if the array length is exceeded or if encoding fails.
Sourcepub fn int(&mut self, v: i64) -> Result<(), CborError>
pub fn int(&mut self, v: i64) -> Result<(), CborError>
Encode a safe-range integer.
§Errors
Returns an error if the array length is exceeded or if encoding fails.
Sourcepub fn bignum(
&mut self,
negative: bool,
magnitude: &[u8],
) -> Result<(), CborError>
pub fn bignum( &mut self, negative: bool, magnitude: &[u8], ) -> Result<(), CborError>
Encode a CBOR bignum (tag 2/3 + byte string magnitude).
§Errors
Returns an error if the array length is exceeded or if encoding fails.
Sourcepub fn bytes(&mut self, b: &[u8]) -> Result<(), CborError>
pub fn bytes(&mut self, b: &[u8]) -> Result<(), CborError>
Encode a byte string.
§Errors
Returns an error if the array length is exceeded or if encoding fails.
Sourcepub fn text(&mut self, s: &str) -> Result<(), CborError>
pub fn text(&mut self, s: &str) -> Result<(), CborError>
Encode a text string.
§Errors
Returns an error if the array length is exceeded or if encoding fails.
Sourcepub fn float(&mut self, bits: F64Bits) -> Result<(), CborError>
pub fn float(&mut self, bits: F64Bits) -> Result<(), CborError>
Encode a float64 bit pattern.
§Errors
Returns an error if the array length is exceeded or if encoding fails.
Sourcepub fn raw_cbor(&mut self, v: CanonicalCborRef<'_>) -> Result<(), CborError>
pub fn raw_cbor(&mut self, v: CanonicalCborRef<'_>) -> Result<(), CborError>
Splice canonical CBOR bytes as the next array element.
§Errors
Returns an error if the array length is exceeded or if encoding fails.
Sourcepub fn raw_value_ref(&mut self, v: CborValueRef<'_>) -> Result<(), CborError>
pub fn raw_value_ref(&mut self, v: CborValueRef<'_>) -> Result<(), CborError>
Splice a canonical sub-value reference as the next array element.
§Errors
Returns an error if the array length is exceeded or if encoding fails.
Sourcepub fn value<T: CborEncode>(&mut self, value: &T) -> Result<(), CborError>
pub fn value<T: CborEncode>(&mut self, value: &T) -> Result<(), CborError>
Encode a value using the native CborEncode trait.
§Errors
Returns an error if the array length is exceeded or if encoding fails.