Skip to main content

ZigZagWriteExt

Trait ZigZagWriteExt 

Source
pub trait ZigZagWriteExt: Output<Item = u8> {
    // Provided methods
    fn write_zig_zag_i8(&mut self, value: i8) -> Result<()> { ... }
    fn write_zig_zag_i16(&mut self, value: i16) -> Result<()> { ... }
    fn write_zig_zag_i32(&mut self, value: i32) -> Result<()> { ... }
    fn write_zig_zag_i64(&mut self, value: i64) -> Result<()> { ... }
    fn write_zig_zag_i128(&mut self, value: i128) -> Result<()> { ... }
    fn write_zig_zag_isize(&mut self, value: isize) -> Result<()> { ... }
}
Expand description

Extension methods for writing ZigZag + unsigned LEB128 integers.

§Target-width integers

isize methods use the current Rust target’s pointer width. Prefer fixed-width integer methods such as Self::write_zig_zag_i64 for persistent files and cross-platform protocols.

§Examples

use qubit_io_binary::ZigZagWriteExt;

let mut bytes = Vec::new();
bytes.write_zig_zag_i32(-300).expect("value should be written");
assert_eq!(bytes, [0xD7, 0x04]);

Provided Methods§

Source

fn write_zig_zag_i8(&mut self, value: i8) -> Result<()>

Writes a ZigZag i8.

§Parameters
  • value: Integer to encode and write.
§Returns

Returns after the canonical payload has been written.

§Errors

Returns an output error, including a write-zero error when the output stops making progress.

Source

fn write_zig_zag_i16(&mut self, value: i16) -> Result<()>

Writes a ZigZag i16.

§Parameters
  • value: Integer to encode and write.
§Returns

Returns after the canonical payload has been written.

§Errors

Returns an output error, including a write-zero error when the output stops making progress.

Source

fn write_zig_zag_i32(&mut self, value: i32) -> Result<()>

Writes a ZigZag i32.

§Parameters
  • value: Integer to encode and write.
§Returns

Returns after the canonical payload has been written.

§Errors

Returns an output error, including a write-zero error when the output stops making progress.

Source

fn write_zig_zag_i64(&mut self, value: i64) -> Result<()>

Writes a ZigZag i64.

§Parameters
  • value: Integer to encode and write.
§Returns

Returns after the canonical payload has been written.

§Errors

Returns an output error, including a write-zero error when the output stops making progress.

Source

fn write_zig_zag_i128(&mut self, value: i128) -> Result<()>

Writes a ZigZag i128.

§Parameters
  • value: Integer to encode and write.
§Returns

Returns after the canonical payload has been written.

§Errors

Returns an output error, including a write-zero error when the output stops making progress.

Source

fn write_zig_zag_isize(&mut self, value: isize) -> Result<()>

Writes a ZigZag isize.

§Parameters
  • value: Integer to encode and write.
§Returns

Returns after the canonical payload has been written.

§Errors

Returns an output error, including a write-zero error when the output stops making progress.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<W> ZigZagWriteExt for W
where W: Output<Item = u8> + ?Sized,