Struct ByteWriter

struct ByteWriter<W: io::Write, E: Endianness> { ... }

For writing aligned bytes to a stream of bytes in a given endianness.

This only writes aligned values and maintains no internal state.

Implementations

impl<W: io::Write, E: Endianness> ByteWriter<W, E>

fn new(writer: W) -> ByteWriter<W, E>

Wraps a ByteWriter around something that implements Write

fn endian(writer: W, _endian: E) -> ByteWriter<W, E>

Wraps a BitWriter around something that implements Write with the given endianness.

fn into_writer(self: Self) -> W

Unwraps internal writer and disposes of ByteWriter. Any unwritten partial bits are discarded.

fn writer(self: &mut Self) -> &mut W

Provides mutable reference to internal writer.

fn into_bitwriter(self: Self) -> BitWriter<W, E>

Converts ByteWriter to BitWriter in the same endianness.

fn bitwriter(self: &mut Self) -> BitWriter<&mut W, E>

Provides temporary BitWriter in the same endianness.

Warning

Any unwritten bits left over when BitWriter is dropped are lost.

impl<T> Any for ByteWriter<W, E>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for ByteWriter<W, E>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for ByteWriter<W, E>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for ByteWriter<W, E>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for ByteWriter<W, E>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for ByteWriter<W, E>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for ByteWriter<W, E>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<W, E> Freeze for ByteWriter<W, E>

impl<W, E> RefUnwindSafe for ByteWriter<W, E>

impl<W, E> Send for ByteWriter<W, E>

impl<W, E> Sync for ByteWriter<W, E>

impl<W, E> Unpin for ByteWriter<W, E>

impl<W, E> UnsafeUnpin for ByteWriter<W, E>

impl<W, E> UnwindSafe for ByteWriter<W, E>

impl<W: io::Write, E: Endianness> ByteWrite for ByteWriter<W, E>

fn write<V>(self: &mut Self, value: V) -> Result<()>
where
    V: Primitive
fn write_as<F, V>(self: &mut Self, value: V) -> Result<()>
where
    F: Endianness,
    V: Primitive
fn write_bytes(self: &mut Self, buf: &[u8]) -> Result<()>
fn writer_ref(self: &mut Self) -> &mut dyn Write