BinaryWriter

Struct BinaryWriter 

Source
pub struct BinaryWriter<'a> {
    pub stream: MemoryStream<'a>,
    pub endian: Endian,
}

Fields§

§stream: MemoryStream<'a>§endian: Endian

Implementations§

Source§

impl<'a> BinaryWriter<'a>

Source

pub fn new_stream<'b>(stream: MemoryStream<'b>, endian: Endian) -> Self
where 'b: 'a,

Createa a new BinaryWriter with predefined data

Source

pub fn new_vec(stream: &'a mut Vec<u8>, endian: Endian) -> Self

Source

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

Write a length-prefixed String to the stream.

The length of the String is written as a usize unless the wasm32 feature is enabled in which case the length is a u32.

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_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 write_bytes_at<B: AsRef<[u8]>>( &mut self, data: B, position: usize, ) -> Result<usize>

Writes bytes at a certain position. Does not go back to it’s original position!

Source

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

Writes a bigstring with an optional position

Source

pub fn write_bytes_with_value( &mut self, count: usize, fill_value: u8, ) -> Result<usize>

Write a byte buffer to the stream.

Source

pub fn swap_endianness(&mut self)

Swap endianness to allow for reversing the writing mid stream

Auto Trait Implementations§

§

impl<'a> Freeze for BinaryWriter<'a>

§

impl<'a> RefUnwindSafe for BinaryWriter<'a>

§

impl<'a> Send for BinaryWriter<'a>

§

impl<'a> Sync for BinaryWriter<'a>

§

impl<'a> Unpin for BinaryWriter<'a>

§

impl<'a> !UnwindSafe for BinaryWriter<'a>

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>,

Source§

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>,

Source§

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.