pub struct Leb128Writer<W> { /* private fields */ }Expand description
Writer wrapper for canonical LEB128 integers.
§Target-width integers
usize and isize methods use the current Rust target’s pointer width.
Prefer fixed-width integer methods such as write_u64 or write_i64 for
persistent files and cross-platform protocols.
Implementations§
Source§impl<W> Leb128Writer<W>
impl<W> Leb128Writer<W>
Sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Consumes this wrapper and returns the underlying writer.
Source§impl<W> Leb128Writer<W>where
W: Write,
impl<W> Leb128Writer<W>where
W: Write,
Sourcepub fn write_u128(&mut self, value: u128) -> Result<()>
pub fn write_u128(&mut self, value: u128) -> Result<()>
Writes an unsigned LEB128 u128.
Sourcepub fn write_usize(&mut self, value: usize) -> Result<()>
pub fn write_usize(&mut self, value: usize) -> Result<()>
Writes an unsigned LEB128 usize.
Sourcepub fn write_i128(&mut self, value: i128) -> Result<()>
pub fn write_i128(&mut self, value: i128) -> Result<()>
Writes a signed LEB128 i128.
Sourcepub fn write_isize(&mut self, value: isize) -> Result<()>
pub fn write_isize(&mut self, value: isize) -> Result<()>
Writes a signed LEB128 isize.
Sourcepub fn write_utf8_string(&mut self, value: &str) -> Result<()>
pub fn write_utf8_string(&mut self, value: &str) -> Result<()>
Writes a UTF-8 string prefixed by an unsigned LEB128 byte length.
The length prefix is encoded as usize, so this format is target-width
dependent. Prefer a fixed-width length prefix for persistent files and
cross-platform protocols.
§Parameters
value: String slice to write.
§Errors
Returns an I/O error from the underlying writer.
Trait Implementations§
Source§impl<W> Seek for Leb128Writer<W>where
W: Seek,
impl<W> Seek for Leb128Writer<W>where
W: Seek,
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Rewind to the beginning of a stream. Read more
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
🔬This is a nightly-only experimental API. (
seek_stream_len)Returns the length of this stream (in bytes). Read more
Source§impl<W> Write for Leb128Writer<W>where
W: Write,
impl<W> Write for Leb128Writer<W>where
W: Write,
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl<W> Freeze for Leb128Writer<W>where
W: Freeze,
impl<W> RefUnwindSafe for Leb128Writer<W>where
W: RefUnwindSafe,
impl<W> Send for Leb128Writer<W>where
W: Send,
impl<W> Sync for Leb128Writer<W>where
W: Sync,
impl<W> Unpin for Leb128Writer<W>where
W: Unpin,
impl<W> UnsafeUnpin for Leb128Writer<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for Leb128Writer<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<W> BinaryWriteExt for W
impl<W> BinaryWriteExt for W
Source§fn write_u16(&mut self, value: u16, byte_order: ByteOrder) -> Result<()>
fn write_u16(&mut self, value: u16, byte_order: ByteOrder) -> Result<()>
Writes an unsigned 16-bit integer using a runtime byte order.
Source§fn write_u16_be(&mut self, value: u16) -> Result<()>
fn write_u16_be(&mut self, value: u16) -> Result<()>
Writes a big-endian unsigned 16-bit integer.
Source§fn write_u16_le(&mut self, value: u16) -> Result<()>
fn write_u16_le(&mut self, value: u16) -> Result<()>
Writes a little-endian unsigned 16-bit integer.
Source§fn write_u32(&mut self, value: u32, byte_order: ByteOrder) -> Result<()>
fn write_u32(&mut self, value: u32, byte_order: ByteOrder) -> Result<()>
Writes an unsigned 32-bit integer using a runtime byte order.
Source§fn write_u32_be(&mut self, value: u32) -> Result<()>
fn write_u32_be(&mut self, value: u32) -> Result<()>
Writes a big-endian unsigned 32-bit integer.
Source§fn write_u32_le(&mut self, value: u32) -> Result<()>
fn write_u32_le(&mut self, value: u32) -> Result<()>
Writes a little-endian unsigned 32-bit integer.
Source§fn write_u64(&mut self, value: u64, byte_order: ByteOrder) -> Result<()>
fn write_u64(&mut self, value: u64, byte_order: ByteOrder) -> Result<()>
Writes an unsigned 64-bit integer using a runtime byte order.
Source§fn write_u64_be(&mut self, value: u64) -> Result<()>
fn write_u64_be(&mut self, value: u64) -> Result<()>
Writes a big-endian unsigned 64-bit integer.
Source§fn write_u64_le(&mut self, value: u64) -> Result<()>
fn write_u64_le(&mut self, value: u64) -> Result<()>
Writes a little-endian unsigned 64-bit integer.
Source§fn write_u128(&mut self, value: u128, byte_order: ByteOrder) -> Result<()>
fn write_u128(&mut self, value: u128, byte_order: ByteOrder) -> Result<()>
Writes an unsigned 128-bit integer using a runtime byte order.
Source§fn write_u128_be(&mut self, value: u128) -> Result<()>
fn write_u128_be(&mut self, value: u128) -> Result<()>
Writes a big-endian unsigned 128-bit integer.
Source§fn write_u128_le(&mut self, value: u128) -> Result<()>
fn write_u128_le(&mut self, value: u128) -> Result<()>
Writes a little-endian unsigned 128-bit integer.
Source§fn write_i16(&mut self, value: i16, byte_order: ByteOrder) -> Result<()>
fn write_i16(&mut self, value: i16, byte_order: ByteOrder) -> Result<()>
Writes a signed 16-bit integer using a runtime byte order.
Source§fn write_i16_be(&mut self, value: i16) -> Result<()>
fn write_i16_be(&mut self, value: i16) -> Result<()>
Writes a big-endian signed 16-bit integer.
Source§fn write_i16_le(&mut self, value: i16) -> Result<()>
fn write_i16_le(&mut self, value: i16) -> Result<()>
Writes a little-endian signed 16-bit integer.
Source§fn write_i32(&mut self, value: i32, byte_order: ByteOrder) -> Result<()>
fn write_i32(&mut self, value: i32, byte_order: ByteOrder) -> Result<()>
Writes a signed 32-bit integer using a runtime byte order.
Source§fn write_i32_be(&mut self, value: i32) -> Result<()>
fn write_i32_be(&mut self, value: i32) -> Result<()>
Writes a big-endian signed 32-bit integer.
Source§fn write_i32_le(&mut self, value: i32) -> Result<()>
fn write_i32_le(&mut self, value: i32) -> Result<()>
Writes a little-endian signed 32-bit integer.
Source§fn write_i64(&mut self, value: i64, byte_order: ByteOrder) -> Result<()>
fn write_i64(&mut self, value: i64, byte_order: ByteOrder) -> Result<()>
Writes a signed 64-bit integer using a runtime byte order.
Source§fn write_i64_be(&mut self, value: i64) -> Result<()>
fn write_i64_be(&mut self, value: i64) -> Result<()>
Writes a big-endian signed 64-bit integer.
Source§fn write_i64_le(&mut self, value: i64) -> Result<()>
fn write_i64_le(&mut self, value: i64) -> Result<()>
Writes a little-endian signed 64-bit integer.
Source§fn write_i128(&mut self, value: i128, byte_order: ByteOrder) -> Result<()>
fn write_i128(&mut self, value: i128, byte_order: ByteOrder) -> Result<()>
Writes a signed 128-bit integer using a runtime byte order.
Source§fn write_i128_be(&mut self, value: i128) -> Result<()>
fn write_i128_be(&mut self, value: i128) -> Result<()>
Writes a big-endian signed 128-bit integer.
Source§fn write_i128_le(&mut self, value: i128) -> Result<()>
fn write_i128_le(&mut self, value: i128) -> Result<()>
Writes a little-endian signed 128-bit integer.
Source§fn write_f32(&mut self, value: f32, byte_order: ByteOrder) -> Result<()>
fn write_f32(&mut self, value: f32, byte_order: ByteOrder) -> Result<()>
Writes a 32-bit float using a runtime byte order.
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
Source§impl<W> Leb128WriteExt for W
impl<W> Leb128WriteExt for W
Source§impl<T> StringWriteExt for T
impl<T> StringWriteExt for T
Source§fn write_utf8_payload(&mut self, value: &str) -> Result<(), Error>
fn write_utf8_payload(&mut self, value: &str) -> Result<(), Error>
Writes a UTF-8 payload without a length prefix. Read more
Source§fn write_utf8_string_uleb(&mut self, value: &str) -> Result<(), Error>
fn write_utf8_string_uleb(&mut self, value: &str) -> Result<(), Error>
Writes a UTF-8 string with an unsigned LEB128 byte-length prefix. Read more
Source§fn write_utf8_string_u16(
&mut self,
value: &str,
byte_order: ByteOrder,
) -> Result<(), Error>
fn write_utf8_string_u16( &mut self, value: &str, byte_order: ByteOrder, ) -> Result<(), Error>
Writes a UTF-8 string with a runtime-order
u16 byte-length prefix. Read moreSource§fn write_utf8_string_u16_be(&mut self, value: &str) -> Result<(), Error>
fn write_utf8_string_u16_be(&mut self, value: &str) -> Result<(), Error>
Writes a UTF-8 string with a big-endian
u16 byte-length prefix. Read moreSource§fn write_utf8_string_u16_le(&mut self, value: &str) -> Result<(), Error>
fn write_utf8_string_u16_le(&mut self, value: &str) -> Result<(), Error>
Writes a UTF-8 string with a little-endian
u16 byte-length prefix. Read moreSource§fn write_utf8_string_u32(
&mut self,
value: &str,
byte_order: ByteOrder,
) -> Result<(), Error>
fn write_utf8_string_u32( &mut self, value: &str, byte_order: ByteOrder, ) -> Result<(), Error>
Writes a UTF-8 string with a runtime-order
u32 byte-length prefix. Read more