Skip to main content

BinaryWriteExt

Trait BinaryWriteExt 

Source
pub trait BinaryWriteExt: ByteOutput {
Show 32 methods // Provided methods fn write_u8(&mut self, value: u8) -> Result<()> { ... } fn write_i8(&mut self, value: i8) -> Result<()> { ... } fn write_u16(&mut self, value: u16, byte_order: ByteOrder) -> Result<()> { ... } fn write_u16_be(&mut self, value: u16) -> Result<()> { ... } fn write_u16_le(&mut self, value: u16) -> Result<()> { ... } fn write_u32(&mut self, value: u32, byte_order: ByteOrder) -> Result<()> { ... } fn write_u32_be(&mut self, value: u32) -> Result<()> { ... } fn write_u32_le(&mut self, value: u32) -> Result<()> { ... } fn write_u64(&mut self, value: u64, byte_order: ByteOrder) -> Result<()> { ... } fn write_u64_be(&mut self, value: u64) -> Result<()> { ... } fn write_u64_le(&mut self, value: u64) -> Result<()> { ... } fn write_u128(&mut self, value: u128, byte_order: ByteOrder) -> Result<()> { ... } fn write_u128_be(&mut self, value: u128) -> Result<()> { ... } fn write_u128_le(&mut self, value: u128) -> Result<()> { ... } fn write_i16(&mut self, value: i16, byte_order: ByteOrder) -> Result<()> { ... } fn write_i16_be(&mut self, value: i16) -> Result<()> { ... } fn write_i16_le(&mut self, value: i16) -> Result<()> { ... } fn write_i32(&mut self, value: i32, byte_order: ByteOrder) -> Result<()> { ... } fn write_i32_be(&mut self, value: i32) -> Result<()> { ... } fn write_i32_le(&mut self, value: i32) -> Result<()> { ... } fn write_i64(&mut self, value: i64, byte_order: ByteOrder) -> Result<()> { ... } fn write_i64_be(&mut self, value: i64) -> Result<()> { ... } fn write_i64_le(&mut self, value: i64) -> Result<()> { ... } fn write_i128(&mut self, value: i128, byte_order: ByteOrder) -> Result<()> { ... } fn write_i128_be(&mut self, value: i128) -> Result<()> { ... } fn write_i128_le(&mut self, value: i128) -> Result<()> { ... } fn write_f32(&mut self, value: f32, byte_order: ByteOrder) -> Result<()> { ... } fn write_f32_be(&mut self, value: f32) -> Result<()> { ... } fn write_f32_le(&mut self, value: f32) -> Result<()> { ... } fn write_f64(&mut self, value: f64, byte_order: ByteOrder) -> Result<()> { ... } fn write_f64_be(&mut self, value: f64) -> Result<()> { ... } fn write_f64_le(&mut self, value: f64) -> Result<()> { ... }
}
Expand description

Extension methods for writing fixed-width binary values to byte streams.

§Partial writes

These methods are not transactional. An output error may occur after the output has accepted a byte prefix of the encoded value, and those bytes are not rolled back. Calling a method again encodes the entire value from the output’s current position and may duplicate that prefix. Recovery requires outer framing, a trusted seek or rollback strategy, or a transactional transport. Output acceptance does not imply durable persistence.

§Examples

use qubit_io_binary::BinaryWriteExt;

let mut output = Vec::new();
output.write_u16_be(0x1234)?;
assert_eq!(output, [0x12, 0x34]);

Provided Methods§

Source

fn write_u8(&mut self, value: u8) -> Result<()>

Writes an unsigned 8-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

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

Writes a signed 8-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u16(&mut self, value: u16, byte_order: ByteOrder) -> Result<()>

Writes an unsigned 16-bit integer using a runtime byte order.

§Parameters
  • value: Scalar to encode and write.
  • byte_order: Byte order used to encode the value.
§Returns

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u16_be(&mut self, value: u16) -> Result<()>

Writes a big-endian unsigned 16-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u16_le(&mut self, value: u16) -> Result<()>

Writes a little-endian unsigned 16-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u32(&mut self, value: u32, byte_order: ByteOrder) -> Result<()>

Writes an unsigned 32-bit integer using a runtime byte order.

§Parameters
  • value: Scalar to encode and write.
  • byte_order: Byte order used to encode the value.
§Returns

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u32_be(&mut self, value: u32) -> Result<()>

Writes a big-endian unsigned 32-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u32_le(&mut self, value: u32) -> Result<()>

Writes a little-endian unsigned 32-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u64(&mut self, value: u64, byte_order: ByteOrder) -> Result<()>

Writes an unsigned 64-bit integer using a runtime byte order.

§Parameters
  • value: Scalar to encode and write.
  • byte_order: Byte order used to encode the value.
§Returns

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u64_be(&mut self, value: u64) -> Result<()>

Writes a big-endian unsigned 64-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u64_le(&mut self, value: u64) -> Result<()>

Writes a little-endian unsigned 64-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u128(&mut self, value: u128, byte_order: ByteOrder) -> Result<()>

Writes an unsigned 128-bit integer using a runtime byte order.

§Parameters
  • value: Scalar to encode and write.
  • byte_order: Byte order used to encode the value.
§Returns

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u128_be(&mut self, value: u128) -> Result<()>

Writes a big-endian unsigned 128-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_u128_le(&mut self, value: u128) -> Result<()>

Writes a little-endian unsigned 128-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_i16(&mut self, value: i16, byte_order: ByteOrder) -> Result<()>

Writes a signed 16-bit integer using a runtime byte order.

§Parameters
  • value: Scalar to encode and write.
  • byte_order: Byte order used to encode the value.
§Returns

Returns after the encoded scalar has been written.

§Errors

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

Source

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

Writes a big-endian signed 16-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

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

Writes a little-endian signed 16-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_i32(&mut self, value: i32, byte_order: ByteOrder) -> Result<()>

Writes a signed 32-bit integer using a runtime byte order.

§Parameters
  • value: Scalar to encode and write.
  • byte_order: Byte order used to encode the value.
§Returns

Returns after the encoded scalar has been written.

§Errors

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

Source

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

Writes a big-endian signed 32-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

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

Writes a little-endian signed 32-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_i64(&mut self, value: i64, byte_order: ByteOrder) -> Result<()>

Writes a signed 64-bit integer using a runtime byte order.

§Parameters
  • value: Scalar to encode and write.
  • byte_order: Byte order used to encode the value.
§Returns

Returns after the encoded scalar has been written.

§Errors

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

Source

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

Writes a big-endian signed 64-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

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

Writes a little-endian signed 64-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_i128(&mut self, value: i128, byte_order: ByteOrder) -> Result<()>

Writes a signed 128-bit integer using a runtime byte order.

§Parameters
  • value: Scalar to encode and write.
  • byte_order: Byte order used to encode the value.
§Returns

Returns after the encoded scalar has been written.

§Errors

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

Source

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

Writes a big-endian signed 128-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

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

Writes a little-endian signed 128-bit integer.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_f32(&mut self, value: f32, byte_order: ByteOrder) -> Result<()>

Writes a 32-bit float using a runtime byte order.

§Parameters
  • value: Scalar to encode and write.
  • byte_order: Byte order used to encode the value.
§Returns

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_f32_be(&mut self, value: f32) -> Result<()>

Writes a big-endian 32-bit float.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_f32_le(&mut self, value: f32) -> Result<()>

Writes a little-endian 32-bit float.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_f64(&mut self, value: f64, byte_order: ByteOrder) -> Result<()>

Writes a 64-bit float using a runtime byte order.

§Parameters
  • value: Scalar to encode and write.
  • byte_order: Byte order used to encode the value.
§Returns

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_f64_be(&mut self, value: f64) -> Result<()>

Writes a big-endian 64-bit float.

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

Returns after the encoded scalar has been written.

§Errors

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

Source

fn write_f64_le(&mut self, value: f64) -> Result<()>

Writes a little-endian 64-bit float.

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

Returns after the encoded scalar 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> BinaryWriteExt for W
where W: ByteOutput + ?Sized,