pub struct ByteWriter { /* private fields */ }Expand description
A checked big-endian writer with a hard output budget.
Implementations§
Source§impl ByteWriter
impl ByteWriter
Sourcepub fn new(budget: usize) -> Self
pub fn new(budget: usize) -> Self
Construct an empty writer that can produce at most budget bytes.
Sourcepub fn write_u2(&mut self, value: u16) -> Result<(), ByteError>
pub fn write_u2(&mut self, value: u16) -> Result<(), ByteError>
Write an unsigned big-endian two-byte integer.
Sourcepub fn write_u4(&mut self, value: u32) -> Result<(), ByteError>
pub fn write_u4(&mut self, value: u32) -> Result<(), ByteError>
Write an unsigned big-endian four-byte integer.
Sourcepub fn write_bytes(&mut self, value: &[u8]) -> Result<(), ByteError>
pub fn write_bytes(&mut self, value: &[u8]) -> Result<(), ByteError>
Append exact bytes after checking the output budget.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Finish and return the written bytes.
Trait Implementations§
Source§impl Clone for ByteWriter
impl Clone for ByteWriter
Source§fn clone(&self) -> ByteWriter
fn clone(&self) -> ByteWriter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ByteWriter
impl RefUnwindSafe for ByteWriter
impl Send for ByteWriter
impl Sync for ByteWriter
impl Unpin for ByteWriter
impl UnsafeUnpin for ByteWriter
impl UnwindSafe for ByteWriter
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