Skip to main content

BufferedIo

Struct BufferedIo 

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

Buffered I/O wrapper providing typed read/write operations. Wraps an IoContext and adds convenience methods for reading integers in specific byte orders.

Implementations§

Source§

impl BufferedIo

Source

pub fn new(inner: Box<dyn IoContext>) -> Self

Source

pub fn take_inner(&mut self) -> Box<dyn IoContext>

Transfer ownership of the inner IoContext out of this BufferedIo. After this call, the BufferedIo is backed by a dead stub — all subsequent I/O operations will return errors.

Source

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

Read exactly buf.len() bytes into buf.

Source

pub fn read_u8(&mut self) -> Result<u8>

Read a single byte.

Source

pub fn read_u16le(&mut self) -> Result<u16>

Read a little-endian u16.

Source

pub fn read_u16be(&mut self) -> Result<u16>

Read a big-endian u16.

Source

pub fn read_u32le(&mut self) -> Result<u32>

Read a little-endian u32.

Source

pub fn read_u32be(&mut self) -> Result<u32>

Read a big-endian u32.

Source

pub fn read_i32le(&mut self) -> Result<i32>

Read a little-endian i32.

Source

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

Read a little-endian u64.

Source

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

Read a big-endian u64.

Source

pub fn read_bytes(&mut self, len: usize) -> Result<Vec<u8>>

Read raw bytes of specified length.

Source

pub fn read_up_to(&mut self, len: usize) -> Result<Vec<u8>>

Read up to len bytes, returning whatever is available. Returns empty Vec only at true EOF. Matches FFmpeg’s av_get_packet() behavior of returning partial data when less than len bytes remain.

Source

pub fn skip(&mut self, n: u64) -> Result<()>

Skip n bytes forward.

Source

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

Seek to an absolute position.

Source

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

Get current position.

Source

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

Get the total size of the underlying source.

Source

pub fn is_seekable(&self) -> bool

Whether the underlying I/O is seekable.

Source

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

Write a single byte.

Source

pub fn write_u16le(&mut self, v: u16) -> Result<()>

Write a little-endian u16.

Source

pub fn write_u16be(&mut self, v: u16) -> Result<()>

Write a big-endian u16.

Source

pub fn write_u32le(&mut self, v: u32) -> Result<()>

Write a little-endian u32.

Source

pub fn write_u32be(&mut self, v: u32) -> Result<()>

Write a big-endian u32.

Source

pub fn write_u64le(&mut self, v: u64) -> Result<()>

Write a little-endian u64.

Source

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

Write raw bytes.

Source

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

Write all bytes from the buffer.

Source

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

Flush buffered write data to the underlying IoContext.

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