Skip to main content

BinaryWriter

Struct BinaryWriter 

Source
pub struct BinaryWriter<W: Write, F: BinaryFormat> { /* private fields */ }
Expand description

Generic binary writer with position tracking.

Implementations§

Source§

impl<W: Write, F: BinaryFormat> BinaryWriter<W, F>

Source

pub fn new(inner: W) -> Self

Create a new binary writer.

Source

pub fn position(&self) -> u64

Get current position.

Source

pub fn add_error(&mut self, error: GaiaError)

Add a diagnostic error.

Source

pub fn take_errors(&mut self) -> Vec<GaiaError>

Take all collected diagnostic errors.

Source

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

Write a u8 value.

Source

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

Write a u16 value.

Source

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

Write a u32 value.

Source

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

Write a u64 value.

Source

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

Write an i16 value.

Source

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

Write an i32 value.

Source

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

Write an i64 value.

Source

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

Write an f32 value.

Source

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

Write an f64 value.

Source

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

Write raw bytes.

Source

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

Write all bytes from a slice.

Source

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

Flush the writer.

Source

pub fn into_inner(self) -> W

Consume the writer and return the inner writer.

Trait Implementations§

Source§

impl<W: Write + Debug, F: BinaryFormat> Debug for BinaryWriter<W, F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<W: Write + Seek, F: BinaryFormat> Seek for BinaryWriter<W, F>

Source§

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

Seek to an offset, in bytes, in a stream. Read more
1.55.0 · Source§

fn rewind(&mut self) -> Result<(), Error>

Rewind to the beginning of a stream. Read more
Source§

fn stream_len(&mut self) -> Result<u64, Error>

🔬This is a nightly-only experimental API. (seek_stream_len)
Returns the length of this stream (in bytes). Read more
1.51.0 · Source§

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

Returns the current seek position from the start of the stream. Read more
1.80.0 · Source§

fn seek_relative(&mut self, offset: i64) -> Result<(), Error>

Seeks relative to the current position. Read more

Auto Trait Implementations§

§

impl<W, F> Freeze for BinaryWriter<W, F>
where W: Freeze,

§

impl<W, F> !RefUnwindSafe for BinaryWriter<W, F>

§

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

§

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

§

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

§

impl<W, F> UnsafeUnpin for BinaryWriter<W, F>
where W: UnsafeUnpin,

§

impl<W, F> !UnwindSafe for BinaryWriter<W, F>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more