Struct FsPool

Source
pub struct FsPool { /* private fields */ }
Expand description

A pool of threads to handle file IO.

Implementations§

Source§

impl FsPool

Source

pub fn new(threads: usize) -> Self

Creates a new FsPool, with the supplied number of threads.

Source

pub fn with_executor<E>(executor: E) -> Self
where E: Executor<Box<dyn Future<Item = (), Error = ()> + Send>> + Send + Sync + 'static,

Creates a new FsPool, from an existing Executor.

§Note

The executor will be used to spawn tasks that can block the thread. It likely should not be an executor that is also handling light-weight tasks, but a dedicated thread pool.

The most common use of this constructor is to allow creating a single CpuPool for your application for blocking tasks, and sharing it with FsPool and any other things needing a thread pool.

Source

pub fn read<P>(&self, path: P, opts: ReadOptions) -> FsReadStream
where P: AsRef<Path> + Send + 'static,

Returns a Stream of the contents of the file at the supplied path.

Source

pub fn read_file(&self, file: File, opts: ReadOptions) -> FsReadStream

Returns a Stream of the contents of the supplied file.

Source

pub fn write<P>(&self, path: P, opts: WriteOptions) -> FsWriteSink
where P: AsRef<Path> + Send + 'static,

Returns a Sink to send bytes to be written to the file at the supplied path.

Source

pub fn write_file(&self, file: File) -> FsWriteSink

Returns a Sink to send bytes to be written to the supplied file.

Source

pub fn delete<P>(&self, path: P) -> FsFuture<()>
where P: AsRef<Path> + Send + 'static,

Returns a Future that resolves when the target file is deleted.

Trait Implementations§

Source§

impl Clone for FsPool

Source§

fn clone(&self) -> FsPool

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FsPool

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for FsPool

Source§

fn default() -> FsPool

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for FsPool

§

impl !RefUnwindSafe for FsPool

§

impl Send for FsPool

§

impl Sync for FsPool

§

impl Unpin for FsPool

§

impl !UnwindSafe for FsPool

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.