Struct sea_streamer_file::AsyncFile
source · pub struct AsyncFile { /* private fields */ }Expand description
A minimal wrapper over async runtime’s File.
Implementations§
source§impl AsyncFile
impl AsyncFile
sourcepub async fn new_rw(id: FileId) -> Result<Self, FileErr>
pub async fn new_rw(id: FileId) -> Result<Self, FileErr>
Creates a new file for Read/Write. If the file already exsits, read from the beginning. Seek to an appropriate position to append to this file.
sourcepub async fn new_ow(id: FileId) -> Result<Self, FileErr>
pub async fn new_ow(id: FileId) -> Result<Self, FileErr>
Creates a new file for Overwrite. If the file already exists, truncate it.
sourcepub async fn new_w(id: FileId) -> Result<Self, FileErr>
pub async fn new_w(id: FileId) -> Result<Self, FileErr>
Always create a new file. If the file already exists, abort.
pub async fn write_all(&mut self, bytes: &[u8]) -> Result<(), FileErr>
pub async fn flush(&mut self) -> Result<(), FileErr>
pub async fn sync_all(&mut self) -> Result<(), 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 position after sought.
sourcepub fn size(&self) -> u64
pub fn size(&self) -> u64
Get the file’s size. This updates only when the file is read or sought.
pub fn pos(&self) -> u64
pub async fn resize(&mut self) -> Result<u64, FileErr>
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for AsyncFile
impl Send for AsyncFile
impl Sync for AsyncFile
impl Unpin for AsyncFile
impl UnwindSafe for AsyncFile
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