pub struct Encoder<'a> { /* private fields */ }Expand description
SIMPLE-TLV encoder.
Implementations§
Source§impl<'a> Encoder<'a>
impl<'a> Encoder<'a>
Sourcepub fn new(bytes: &'a mut [u8]) -> Self
pub fn new(bytes: &'a mut [u8]) -> Self
Create a new encoder with the given byte slice as a backing buffer.
Sourcepub fn encode<T: Encodable>(&mut self, encodable: &T) -> Result<()>
pub fn encode<T: Encodable>(&mut self, encodable: &T) -> Result<()>
Encode a value which impls the Encodable trait.
Sourcepub fn error<T>(&mut self, kind: ErrorKind) -> Result<T>
pub fn error<T>(&mut self, kind: ErrorKind) -> Result<T>
Return an error with the given ErrorKind, annotating it with
context about where the error occurred.
Sourcepub fn finish(self) -> Result<&'a [u8]>
pub fn finish(self) -> Result<&'a [u8]>
Finish encoding to the buffer, returning a slice containing the data written to the buffer.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Encoder<'a>
impl<'a> RefUnwindSafe for Encoder<'a>
impl<'a> Send for Encoder<'a>
impl<'a> Sync for Encoder<'a>
impl<'a> Unpin for Encoder<'a>
impl<'a> !UnwindSafe for Encoder<'a>
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