pub trait Env: Clone + Send + Sync + 'static {
type PositionalReader: PositionalReader;
type SequentialWriter: SequentialWriter;
type JoinHandle<T: Send>: Future<Output = T> + Send;
type Directory: Directory + Send + Sync + 'static;
fn open_positional_reader<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<Self::PositionalReader>> + Send + 'async_trait>>
where
P: AsRef<Path> + Send,
P: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait;
fn open_sequential_writer<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<Self::SequentialWriter>> + Send + 'async_trait>>
where
P: AsRef<Path> + Send,
P: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait;
fn spawn_background<F>(&self, f: F) -> Self::JoinHandle<F::Output>
where
F: Future + Send + 'static,
F::Output: Send;
fn rename<'life0, 'async_trait, P, Q>(
&'life0 self,
from: P,
to: Q
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send,
Q: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait;
fn remove_file<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait;
fn create_dir_all<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait;
fn remove_dir_all<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait;
fn read_dir<P: AsRef<Path>>(&self, path: P) -> Result<ReadDir>;
fn metadata<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<Metadata>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait;
fn open_dir<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<Self::Directory>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait;
}
Expand description
Provides an environment to interact with a specific platform.
Required Associated Types§
sourcetype PositionalReader: PositionalReader
type PositionalReader: PositionalReader
Positional readers returned by the environment.
sourcetype SequentialWriter: SequentialWriter
type SequentialWriter: SequentialWriter
Sequential writers returned by the environment.
sourcetype JoinHandle<T: Send>: Future<Output = T> + Send
type JoinHandle<T: Send>: Future<Output = T> + Send
Handles to await tasks spawned by the environment.
Required Methods§
sourcefn open_positional_reader<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<Self::PositionalReader>> + Send + 'async_trait>>where
P: AsRef<Path> + Send,
P: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn open_positional_reader<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<Self::PositionalReader>> + Send + 'async_trait>>where
P: AsRef<Path> + Send,
P: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Opens a file for positional reads.
sourcefn open_sequential_writer<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<Self::SequentialWriter>> + Send + 'async_trait>>where
P: AsRef<Path> + Send,
P: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn open_sequential_writer<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<Self::SequentialWriter>> + Send + 'async_trait>>where
P: AsRef<Path> + Send,
P: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Opens a file for sequential writes.
sourcefn spawn_background<F>(&self, f: F) -> Self::JoinHandle<F::Output>where
F: Future + Send + 'static,
F::Output: Send,
fn spawn_background<F>(&self, f: F) -> Self::JoinHandle<F::Output>where
F: Future + Send + 'static,
F::Output: Send,
Spawns a task to run in the background.
sourcefn rename<'life0, 'async_trait, P, Q>(
&'life0 self,
from: P,
to: Q
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send,
Q: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait,
fn rename<'life0, 'async_trait, P, Q>(
&'life0 self,
from: P,
to: Q
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send,
Q: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait,
An async version of std::fs::rename
.
sourcefn remove_file<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait,
fn remove_file<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait,
Removes a file from the filesystem.
See also std::fs::remove_file
.
sourcefn create_dir_all<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait,
fn create_dir_all<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait,
Recursively create a directory and all of its parent components if they
are missing.
See also std::fs::create_dir_all
.
sourcefn remove_dir_all<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait,
fn remove_dir_all<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait,
Removes a directory at this path, after removing all its contents.
See also std::fs::remove_dir_all
.
sourcefn read_dir<P: AsRef<Path>>(&self, path: P) -> Result<ReadDir>
fn read_dir<P: AsRef<Path>>(&self, path: P) -> Result<ReadDir>
Returns an iterator over the entries within a directory.
See also std::fs::read_dir
.
TODO: async iterator impl?
sourcefn metadata<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<Metadata>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait,
fn metadata<'life0, 'async_trait, P>(
&'life0 self,
path: P
) -> Pin<Box<dyn Future<Output = Result<Metadata>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send,
'life0: 'async_trait,
Self: 'async_trait,
Given a path, query the file system to get information about a file,
directory, etc.
See also std::fs::metadata
.