pub struct Encoder { /* private fields */ }Implementations§
Source§impl Encoder
impl Encoder
pub fn new(writer: Vec<u8>) -> Self
pub fn begin_map(&mut self) -> &mut Self
pub fn begin_array(&mut self) -> &mut Self
pub fn boolean(&mut self, x: bool) -> &mut Self
pub fn byte(&mut self, x: i8) -> &mut Self
pub fn short(&mut self, x: i16) -> &mut Self
pub fn integer(&mut self, x: i32) -> &mut Self
pub fn long(&mut self, x: i64) -> &mut Self
pub fn float(&mut self, x: f32) -> &mut Self
pub fn double(&mut self, x: f64) -> &mut Self
pub fn null(&mut self) -> &mut Self
pub fn end(&mut self) -> &mut Self
Sourcepub fn str(&mut self, x: &str) -> &mut Self
pub fn str(&mut self, x: &str) -> &mut Self
Writes a definite length string. Collapses header+data into a single reserve+write.
Sourcepub fn big_integer(&mut self, value: &BigInteger) -> &mut Self
pub fn big_integer(&mut self, value: &BigInteger) -> &mut Self
Writes a BigInteger using preferred serialization per RFC 8949 §3.4.3.
Values that fit in a CBOR major type 0 or 1 integer are encoded directly
(preferred serialization). Larger values use tag 2 (unsigned bignum) or
tag 3 (negative bignum). For tag 3, the byte string encodes n where
the value is -1 - n.
Sourcepub fn blob_bytes(&mut self, data: &[u8]) -> &mut Self
pub fn blob_bytes(&mut self, data: &[u8]) -> &mut Self
Writes a blob from a byte slice. Collapses header+data into a single reserve+write.
Mirrors Self::str’s slice-input style. Prefer this over Self::blob
when the caller already holds a &[u8] (e.g. from a schema-serde
ShapeSerializer::write_blob(_, &[u8]) call) — it avoids needing to
wrap the bytes in a [Blob] just to satisfy the API.
Sourcepub fn blob(&mut self, x: &Blob) -> &mut Self
pub fn blob(&mut self, x: &Blob) -> &mut Self
Writes a blob. Collapses header+data into a single reserve+write.
Sourcepub fn map(&mut self, len: usize) -> &mut Self
pub fn map(&mut self, len: usize) -> &mut Self
Writes a fixed length map of given length. Used when we know the size in advance, i.e.:
- when a struct has all non-
Optional members. - when serializing
unionshapes (they can only have one member set). - when serializing a
mapshape.
pub fn timestamp(&mut self, x: &DateTime) -> &mut Self
pub fn into_writer(self) -> Vec<u8> ⓘ
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Encoder
impl RefUnwindSafe for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin for Encoder
impl UnsafeUnpin for Encoder
impl UnwindSafe for Encoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more