pub struct Encoder { /* private fields */ }Expand description
The Encoder struct provides methods for packing values that implement the
Packer trait.
§Examples
use antelope::serializer::{Encoder, Packer};
let mut encoder = Encoder::new(4);
let value = 123u32;
let bytes_written = value.pack(&mut encoder);
assert_eq!(bytes_written, 4);
let packed_bytes = encoder.get_bytes();
assert_eq!(packed_bytes, [123, 0, 0, 0]);Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn get_bytes(&self) -> &[u8] ⓘ
pub fn get_bytes(&self) -> &[u8] ⓘ
Returns the packed bytes of this encoder as a byte array.
§Returns
A reference to the packed bytes of this encoder as a byte array.
Sourcepub fn get_size(&self) -> usize
pub fn get_size(&self) -> usize
Returns the number of packed bytes in this encoder.
§Returns
The number of packed bytes in this encoder.
Auto Trait Implementations§
impl Freeze for Encoder
impl RefUnwindSafe for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin 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
Mutably borrows from an owned value. Read more