pub struct File(_);Expand description
A wrapper around a std::fs::File that implements AsyncSliceReader and AsyncSliceWriter
Implementations§
source§impl File
impl File
sourcepub async fn create(
create_file: impl Fn() -> Result<File> + Send + 'static
) -> Result<Self>
pub async fn create( create_file: impl Fn() -> Result<File> + Send + 'static ) -> Result<Self>
Create a new File from a function that creates a std::fs::File
sourcepub fn from_std(file: File) -> Self
pub fn from_std(file: File) -> Self
Create a new File from a std::fs::File
This is fine if you already have a std::fs::File and want to use it with File, but opening a file is a blocking op that you probably don’t want to do in an async context.
Trait Implementations§
source§impl AsyncSliceReader for File
impl AsyncSliceReader for File
§type ReadAtFuture<'a> = ReadAtFuture<'a>
type ReadAtFuture<'a> = ReadAtFuture<'a>
The future returned by read_at
source§impl AsyncSliceWriter for File
impl AsyncSliceWriter for File
§type WriteBytesAtFuture<'a> = WriteBytesAtFuture<'a>
type WriteBytesAtFuture<'a> = WriteBytesAtFuture<'a>
The future returned by write_bytes_at
source§fn write_bytes_at(
&mut self,
offset: u64,
data: Bytes
) -> Self::WriteBytesAtFuture<'_>
fn write_bytes_at( &mut self, offset: u64, data: Bytes ) -> Self::WriteBytesAtFuture<'_>
Write the entire Bytes at the given position. Read more
§type WriteAtFuture<'a> = WriteAtFuture<'a>
type WriteAtFuture<'a> = WriteAtFuture<'a>
The future returned by write_at
source§fn write_at(&mut self, offset: u64, data: &[u8]) -> Self::WriteAtFuture<'_>
fn write_at(&mut self, offset: u64, data: &[u8]) -> Self::WriteAtFuture<'_>
Write the entire slice at the given position. Read more
§type SyncFuture<'a> = SyncFuture<'a>
type SyncFuture<'a> = SyncFuture<'a>
The future returned by sync
source§fn sync(&mut self) -> Self::SyncFuture<'_>
fn sync(&mut self) -> Self::SyncFuture<'_>
Sync any buffers to the underlying storage.
§type SetLenFuture<'a> = SetLenFuture<'a>
type SetLenFuture<'a> = SetLenFuture<'a>
The future returned by set_len
source§fn set_len(&mut self, len: u64) -> Self::SetLenFuture<'_>
fn set_len(&mut self, len: u64) -> Self::SetLenFuture<'_>
Set the length of the underlying storage.
Auto Trait Implementations§
impl RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnwindSafe for File
Blanket Implementations§
source§impl<T> AsyncSliceReaderExt for Twhere
T: AsyncSliceReader,
impl<T> AsyncSliceReaderExt for Twhere T: AsyncSliceReader,
source§fn read_to_end(&mut self) -> Self::ReadAtFuture<'_>
fn read_to_end(&mut self) -> Self::ReadAtFuture<'_>
Read the entire resource into a bytes::Bytes buffer, if possible.
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