Struct sea_streamer_file::FileReader
source · pub struct FileReader { /* private fields */ }
Expand description
A simple buffered and bounded file reader.
The implementation is much simpler than FileSource
.
FileReader
treats file as a fixed depot of bytes.
Attempt to read beyond the end will result in a NotEnoughBytes
error.
Implementations§
source§impl FileReader
impl FileReader
pub async fn new(file_id: FileId) -> Result<Self, FileErr>
sourcepub async fn seek(&mut self, to: SeqPos) -> Result<u64, FileErr>
pub async fn seek(&mut self, to: SeqPos) -> Result<u64, FileErr>
Seek the file stream to a different position. SeqNo is regarded as byte offset. Returns the file offset after sought.
pub fn offset(&self) -> u64
pub fn file_size(&self) -> u64
pub async fn resize(&mut self) -> Result<u64, FileErr>
Trait Implementations§
source§impl ByteSource for FileReader
impl ByteSource for FileReader
source§fn request_bytes(&mut self, size: usize) -> Self::Future<'_>
fn request_bytes(&mut self, size: usize) -> Self::Future<'_>
Read N bytes from file. If there is not enough bytes, it will return NotEnoughBytes
error.
If there are enough bytes in the buffer, it yields immediately.
type Future<'a> = Pin<Box<dyn Future<Output = Result<Bytes, FileErr>> + Send + 'a>>
Auto Trait Implementations§
impl Freeze for FileReader
impl RefUnwindSafe for FileReader
impl Send for FileReader
impl Sync for FileReader
impl Unpin for FileReader
impl UnwindSafe for FileReader
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more