StreamSlice

Struct StreamSlice 

Source
pub struct StreamSlice<T: Read + Write + Seek> { /* private fields */ }
Expand description

Stream wrapper for accessing limited segment of data from underlying file or device.

Implementations§

Source§

impl<T: Read + Write + Seek> StreamSlice<T>

Source

pub async fn new( inner: T, start_offset: u64, end_offset: u64, ) -> Result<Self, StreamSliceError<T::Error>>

Creates new StreamSlice from inner stream and offset range.

start_offset is inclusive offset of the first accessible byte. end_offset is exclusive offset of the first non-accessible byte. start_offset must be lower or equal to end_offset.

Source

pub fn into_inner(self) -> T

Returns inner object

Trait Implementations§

Source§

impl<T: Read + Write + Seek> ErrorType for StreamSlice<T>

Source§

type Error = StreamSliceError<<T as ErrorType>::Error>

Error type of all the IO operations on this type.
Source§

impl<T: Read + Write + Seek> Read for StreamSlice<T>

Source§

async fn read( &mut self, buf: &mut [u8], ) -> Result<usize, StreamSliceError<T::Error>>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

async fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl<T: Read + Write + Seek> Seek for StreamSlice<T>

Source§

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

Seek to an offset, in bytes, in a stream.
Source§

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

Rewind to the beginning of a stream.
Source§

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

Returns the current seek position from the start of the stream.
Source§

impl<T: Read + Write + Seek> Write for StreamSlice<T>

Source§

async fn write( &mut self, buf: &[u8], ) -> Result<usize, StreamSliceError<T::Error>>

Write a buffer into this writer, returning how many bytes were written. Read more
Source§

async fn flush(&mut self) -> Result<(), StreamSliceError<T::Error>>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination.
Source§

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

Write an entire buffer into this writer. Read more

Auto Trait Implementations§

§

impl<T> Freeze for StreamSlice<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for StreamSlice<T>
where T: RefUnwindSafe,

§

impl<T> Send for StreamSlice<T>
where T: Send,

§

impl<T> Sync for StreamSlice<T>
where T: Sync,

§

impl<T> Unpin for StreamSlice<T>
where T: Unpin,

§

impl<T> UnwindSafe for StreamSlice<T>
where T: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.