Trait bitstream_io::write::BitWrite [] [src]

pub trait BitWrite {
    fn write<U>(&mut self, bits: u32, value: U) -> Result<(), Error> where U: Numeric;
    fn write_signed<S>(&mut self, bits: u32, value: S) -> Result<(), Error> where S: SignedNumeric;
    fn write_bytes(&mut self, buf: &[u8]) -> Result<(), Error>;
    fn byte_aligned(&self) -> bool;

    fn write_unary0(&mut self, value: u32) -> Result<(), Error> { ... }
    fn write_unary1(&mut self, value: u32) -> Result<(), Error> { ... }
    fn byte_align(&mut self) -> Result<(), Error> { ... }
}

For writing bit values to an underlying stream in a given endianness.

Because this only writes whole bytes to the underlying stream, it is important that output is byte-aligned before the bitstream writer's lifetime ends. Partial bytes will be lost if the writer is disposed of before they can be written.

Required Methods

Writes an unsigned value to the stream using the given number of bits. This method assumes that value's type is sufficiently large to hold those bits.

Writes a twos-complement signed value to the stream with the given number of bits. This method assumes that value's type is sufficiently large to hold those bits.

Writes the entirety of a byte buffer to the stream. If the stream is already byte-aligned, it will often map to a faster write_all call. Otherwise it will write bytes individually in 8-bit increments.

Returns true if the stream is aligned at a whole byte.

Provided Methods

Writes value number of 1 bits to the stream and then writes a 0 bit. This field is variably-sized.

Writes value number of 0 bits to the stream and then writes a 1 bit. This field is variably-sized.

Pads the stream with 0 bits until is aligned at a whole byte. Does nothing if the stream is already aligned.

Implementors