pub struct BinaryWriter<W>
where W: Write + Seek,
{ /* private fields */ }
Expand description

Write to a stream.

Implementations§

source§

impl<W: Write + Seek> BinaryWriter<W>

source

pub fn new(stream: W, options: Options) -> Self

Create a binary writer with the given options.

source

pub fn seek(&mut self, to: SeekFrom) -> Result<u64>

Seek to a position.

source

pub fn stream_position(&mut self) -> Result<u64>

Get the current seek position.

source

pub fn len(&mut self) -> Result<u64>

Get the length of this stream by seeking to the end and then restoring the previous cursor position.

source

pub fn write_string<S: AsRef<str>>(&mut self, value: S) -> Result<usize>

Write a length-prefixed String to the stream.

source

pub fn write_char<V: Borrow<char>>(&mut self, v: V) -> Result<usize>

Write a character to the stream.

source

pub fn write_bool<V: Borrow<bool>>(&mut self, value: V) -> Result<usize>

Write a bool to the stream.

source

pub fn write_f32<V: Borrow<f32>>(&mut self, value: V) -> Result<usize>

Write a f32 to the stream.

source

pub fn write_f64<V: Borrow<f64>>(&mut self, value: V) -> Result<usize>

Write a f64 to the stream.

source

pub fn write_isize<V: Borrow<isize>>(&mut self, value: V) -> Result<usize>

Write an isize to the stream.

source

pub fn write_usize<V: Borrow<usize>>(&mut self, value: V) -> Result<usize>

Write a usize to the stream.

source

pub fn write_u64<V: Borrow<u64>>(&mut self, value: V) -> Result<usize>

Write a u64 to the stream.

source

pub fn write_i64<V: Borrow<i64>>(&mut self, value: V) -> Result<usize>

Write an i64 to the stream.

source

pub fn write_u128<V: Borrow<u128>>(&mut self, value: V) -> Result<usize>

Write a u128 to the stream.

source

pub fn write_i128<V: Borrow<i128>>(&mut self, value: V) -> Result<usize>

Write an i128 to the stream.

source

pub fn write_u32<V: Borrow<u32>>(&mut self, value: V) -> Result<usize>

Write a u32 to the stream.

source

pub fn write_i32<V: Borrow<i32>>(&mut self, value: V) -> Result<usize>

Write an i32 to the stream.

source

pub fn write_u16<V: Borrow<u16>>(&mut self, value: V) -> Result<usize>

Write a u16 to the stream.

source

pub fn write_i16<V: Borrow<i16>>(&mut self, value: V) -> Result<usize>

Write an i16 to the stream.

source

pub fn write_u8<V: Borrow<u8>>(&mut self, value: V) -> Result<usize>

Write a u8 to the stream.

source

pub fn write_i8<V: Borrow<i8>>(&mut self, value: V) -> Result<usize>

Write an i8 to the stream.

source

pub fn write_bytes<B: AsRef<[u8]>>(&mut self, data: B) -> Result<usize>

Write a byte buffer to the stream.

source

pub fn flush(&mut self) -> Result<()>

Flush the write buffer.

Auto Trait Implementations§

§

impl<W> RefUnwindSafe for BinaryWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for BinaryWriter<W>
where W: Send,

§

impl<W> Sync for BinaryWriter<W>
where W: Sync,

§

impl<W> Unpin for BinaryWriter<W>
where W: Unpin,

§

impl<W> UnwindSafe for BinaryWriter<W>
where W: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.