pub struct Writer<'b> { /* private fields */ }Expand description
A cursor that writes SML values into a caller-provided buffer.
Used by the tests and simulators; a meter readout client never needs it.
Debug shows the position and capacity, never the bytes.
Implementations§
Source§impl<'b> Writer<'b>
impl<'b> Writer<'b>
Sourcepub fn tl(&mut self, kind: Kind, len: usize) -> Result<()>
pub fn tl(&mut self, kind: Kind, len: usize) -> Result<()>
Write a type-length field. len is the element count for a list and the number
of data bytes otherwise.
Sourcepub fn octet_string(&mut self, bytes: &[u8]) -> Result<()>
pub fn octet_string(&mut self, bytes: &[u8]) -> Result<()>
Write an octet string.
Sourcepub fn unsigned(&mut self, v: u64, width: usize) -> Result<()>
pub fn unsigned(&mut self, v: u64, width: usize) -> Result<()>
Write an unsigned integer in exactly width bytes (1, 2, 4 or 8 for the SML
types Unsigned8 to Unsigned64).
Sourcepub fn integer(&mut self, v: i64, width: usize) -> Result<()>
pub fn integer(&mut self, v: i64, width: usize) -> Result<()>
Write a signed integer in exactly width bytes.
Sourcepub fn unsigned_min(&mut self, v: u64) -> Result<()>
pub fn unsigned_min(&mut self, v: u64) -> Result<()>
Write an unsigned integer in the smallest of 1, 2, 4 or 8 bytes that holds it.
Sourcepub fn integer_min(&mut self, v: i64) -> Result<()>
pub fn integer_min(&mut self, v: i64) -> Result<()>
Write a signed integer in the smallest of 1, 2, 4 or 8 bytes that holds it.
Sourcepub fn opt_octet_string(&mut self, bytes: Option<&[u8]>) -> Result<()>
pub fn opt_octet_string(&mut self, bytes: Option<&[u8]>) -> Result<()>
Write an optional octet string: the absent marker for None.
Sourcepub fn end_of_message(&mut self) -> Result<()>
pub fn end_of_message(&mut self) -> Result<()>
Write the end-of-message marker.
Trait Implementations§
Auto Trait Implementations§
impl<'b> !UnwindSafe for Writer<'b>
impl<'b> Forget for Writer<'b>
impl<'b> Freeze for Writer<'b>
impl<'b> Move for Writer<'b>
impl<'b> RefUnwindSafe for Writer<'b>
impl<'b> Send for Writer<'b>
impl<'b> Sync for Writer<'b>
impl<'b> Unpin for Writer<'b>
impl<'b> UnsafeUnpin for Writer<'b>where
&'b mut [u8]: UnsafeUnpin,
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