[−][src]Struct bitstream_io::write::ByteWriter
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: Write, E: Endianness> ByteWriter<W, E>
[src]
pub fn new(writer: W) -> ByteWriter<W, E>
[src]
Wraps a ByteWriter around something that implements Write
pub fn endian(writer: W, _endian: E) -> ByteWriter<W, E>
[src]
Wraps a BitWriter around something that implements Write
with the given endianness.
pub fn into_writer(self) -> W
[src]
Unwraps internal writer and disposes of ByteWriter
.
Any unwritten partial bits are discarded.
pub fn writer(&mut self) -> &mut W
[src]
Provides mutable reference to internal writer.
pub fn into_bitwriter(self) -> BitWriter<W, E>
[src]
Converts ByteWriter
to BitWriter
in the same endianness.
pub fn bitwriter(&mut self) -> BitWriter<&mut W, E>
[src]
Provides temporary BitWriter
in the same endianness.
Warning
Any unwritten bits left over when BitWriter
is dropped are lost.
pub fn write<N: Numeric>(&mut self, value: N) -> Result<()>
[src]
Writes whole numeric value to stream
Errors
Passes along any I/O error from the underlying stream.
Examples
use std::io::Write; use bitstream_io::{BigEndian, ByteWriter}; let mut writer = ByteWriter::endian(Vec::new(), BigEndian); writer.write(0b0000000011111111u16).unwrap(); assert_eq!(writer.into_writer(), [0b00000000, 0b11111111]);
use std::io::Write; use bitstream_io::{LittleEndian, ByteWriter}; let mut writer = ByteWriter::endian(Vec::new(), LittleEndian); writer.write(0b0000000011111111u16).unwrap(); assert_eq!(writer.into_writer(), [0b11111111, 0b00000000]);
pub fn write_bytes(&mut self, buf: &[u8]) -> Result<()>
[src]
Writes the entirety of a byte buffer to the stream.
Errors
Passes along any I/O error from the underlying stream.
Auto Trait Implementations
impl<W, E> RefUnwindSafe for ByteWriter<W, E> where
E: RefUnwindSafe,
W: RefUnwindSafe,
E: RefUnwindSafe,
W: RefUnwindSafe,
impl<W, E> Send for ByteWriter<W, E> where
E: Send,
W: Send,
E: Send,
W: Send,
impl<W, E> Sync for ByteWriter<W, E> where
E: Sync,
W: Sync,
E: Sync,
W: Sync,
impl<W, E> Unpin for ByteWriter<W, E> where
E: Unpin,
W: Unpin,
E: Unpin,
W: Unpin,
impl<W, E> UnwindSafe for ByteWriter<W, E> where
E: UnwindSafe,
W: UnwindSafe,
E: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,