DetectionSource

Trait DetectionSource 

Source
pub trait DetectionSource {
    // Required methods
    fn read_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<usize>;
    fn total_len(&self) -> Option<u64>;

    // Provided methods
    fn read_bof(&mut self, max_len: usize) -> Result<Vec<u8>> { ... }
    fn read_eof(&mut self, max_len: usize) -> Result<Vec<u8>> { ... }
}
Expand description

Abstraction for streamed or buffered payload access during format detection.

Required Methods§

Source

fn read_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<usize>

Reads up to buf.len() bytes at the specified offset.

Source

fn total_len(&self) -> Option<u64>

Total logical length of payload in bytes if known.

Provided Methods§

Source

fn read_bof(&mut self, max_len: usize) -> Result<Vec<u8>>

Reads up to max_len bytes from the beginning of the file (BOF).

Source

fn read_eof(&mut self, max_len: usize) -> Result<Vec<u8>>

Reads up to max_len bytes backwards from the end of the file (EOF).

Implementations on Foreign Types§

Source§

impl DetectionSource for &[u8]

Source§

fn read_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<usize>

Source§

fn total_len(&self) -> Option<u64>

Source§

impl DetectionSource for Vec<u8>

Source§

fn read_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<usize>

Source§

fn total_len(&self) -> Option<u64>

Source§

impl<S: DetectionSource + ?Sized> DetectionSource for &mut S

Source§

fn read_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<usize>

Source§

fn read_bof(&mut self, max_len: usize) -> Result<Vec<u8>>

Source§

fn read_eof(&mut self, max_len: usize) -> Result<Vec<u8>>

Source§

fn total_len(&self) -> Option<u64>

Source§

impl<T: AsRef<[u8]> + Send> DetectionSource for Cursor<T>

Source§

fn read_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<usize>

Source§

fn total_len(&self) -> Option<u64>

Implementors§