Struct fs::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) -> Selfwhere 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) -> FsReadStreamwhere 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) -> FsWriteSinkwhere 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 !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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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> ToOwned for Twhere T: Clone,

§

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 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.