Skip to main content

FileBackend

Struct FileBackend 

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

Seekable file-backed media source.

This backend can copy byte ranges with MediaReadAt::read_at, but it does not expose borrowed windows. A future sliding-window backend can build on the same typed range/error contract while adding cache-backed window_at.

Implementations§

Source§

impl FileBackend

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self, ReadAtError>

Source

pub fn from_file(file: File) -> Result<Self, ReadAtError>

Trait Implementations§

Source§

impl Debug for FileBackend

Source§

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

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

impl MediaReadAt for FileBackend

Source§

fn len_u64(&self) -> u64

Total length of the source in bytes.
Source§

fn read_at( &self, range: ByteRange, dst: &mut [u8], ) -> Result<usize, ReadAtError>

Copy exactly range.len bytes into dst.
Source§

fn window_at(&self, _range: ByteRange) -> Result<&[u8], ReadAtError>

Borrow exactly range.len bytes from the source.
Source§

fn is_empty(&self) -> bool

Source§

fn window_at_partial(&self, range: ByteRange) -> Result<&[u8], ReadAtError>

Borrow up to range.len bytes. The offset must still be in bounds.
Source§

fn as_contiguous(&self) -> Option<&[u8]>

Return the complete contiguous source only for compatibility paths.
Source§

fn stats(&self) -> SourceStats

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.