Struct EndianFile

Source
pub struct EndianFile { /* private fields */ }
Expand description

Helper structure that provides convenience methods to write to a fs::File, being aware of the file’s Endianness.

Implementations§

Source§

impl EndianFile

Source

pub fn write_u8(&mut self, n: u8) -> Result<()>

Writes a u8 to the file.

§Errors

This method returns the same errors as Write::write_all.

Source

pub fn write_all_u8(&mut self, bytes: &[u8]) -> Result<()>

Writes a slice of bytes to a file.

This is much more efficient than calling [write_u8] in a loop if you have list of bytes to write.

§Errors

This method returns the same errors as Write::write_all.

Source

pub fn write_u16(&mut self, n: u16) -> Result<()>

Writes a u16 to the file.

§Errors

This method returns the same errors as Write::write_all.

Source

pub fn write_u32(&mut self, n: u32) -> Result<()>

Writes a u32 to the file.

§Errors

This method returns the same errors as Write::write_all.

Source

pub fn write_i8(&mut self, n: i8) -> Result<()>

Writes a i8 to the file.

§Errors

This method returns the same errors as Write::write_all.

Source

pub fn write_i16(&mut self, n: i16) -> Result<()>

Writes a i16 to the file.

§Errors

This method returns the same errors as Write::write_all.

Source

pub fn write_i32(&mut self, n: i32) -> Result<()>

Writes a i32 to the file.

§Errors

This method returns the same errors as Write::write_all.

Source

pub fn write_f32(&mut self, n: f32) -> Result<()>

Writes a f32 to the file.

§Errors

This method returns the same errors as Write::write_all.

Source

pub fn write_f64(&mut self, n: f64) -> Result<()>

Writes a f64 to the file.

§Errors

This method returns the same errors as Write::write_all.

Trait Implementations§

Source§

impl Into<File> for EndianFile

Source§

fn into(self) -> File

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

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.