Struct iroh_io::File

source ·
pub struct File(_);
Expand description

A wrapper around a std::fs::File that implements AsyncSliceReader and AsyncSliceWriter

Implementations§

source§

impl File

source

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

source

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.

source

pub async fn open(path: PathBuf) -> Result<Self>

Open a File from a path

Trait Implementations§

source§

impl AsyncSliceReader for File

§

type ReadAtFuture<'a> = ReadAtFuture<'a>

The future returned by read_at
source§

fn read_at(&mut self, offset: u64, len: usize) -> Self::ReadAtFuture<'_>

Read the entire buffer at the given position. Read more
§

type LenFuture<'a> = LenFuture<'a>

The future returned by len
source§

fn len(&mut self) -> Self::LenFuture<'_>

Get the length of the resource
source§

impl AsyncSliceWriter for File

§

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<'_>

Write the entire Bytes at the given position. Read more
§

type WriteAtFuture<'a> = WriteAtFuture<'a>

The future returned by write_at
source§

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>

The future returned by sync
source§

fn sync(&mut self) -> Self::SyncFuture<'_>

Sync any buffers to the underlying storage.
§

type SetLenFuture<'a> = SetLenFuture<'a>

The future returned by set_len
source§

fn set_len(&mut self, len: u64) -> Self::SetLenFuture<'_>

Set the length of the underlying storage.
source§

impl Debug for File

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsyncSliceReaderExt for Twhere T: AsyncSliceReader,

source§

fn read_to_end(&mut self) -> Self::ReadAtFuture<'_>

Read the entire resource into a bytes::Bytes buffer, if possible.
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

source§

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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

§

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

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

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

Performs the conversion.