pub struct LocalFilesystem { /* private fields */ }Expand description
Files under one root directory.
Every path is normalised and then joined to the root, and the result is checked to still be inside it. Two independent guards, because the consequence of getting it wrong is reading or writing anywhere the process can reach.
Implementations§
Source§impl LocalFilesystem
impl LocalFilesystem
Sourcepub fn new(root: impl Into<PathBuf>) -> LocalFilesystem
pub fn new(root: impl Into<PathBuf>) -> LocalFilesystem
Files under root.
Sourcepub fn with_url_prefix(self, prefix: impl Into<String>) -> LocalFilesystem
pub fn with_url_prefix(self, prefix: impl Into<String>) -> LocalFilesystem
The URL prefix files under this root are reachable at.
Only meaningful if something — nginx, a CDN, a route you wrote — actually
serves the directory. Without it url is None,
because a link that 404s is worse than no link.
Trait Implementations§
Source§impl Debug for LocalFilesystem
impl Debug for LocalFilesystem
Source§impl Filesystem for LocalFilesystem
impl Filesystem for LocalFilesystem
Source§fn get<'a>(
&'a self,
path: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, Error>> + Send + 'a>>
fn get<'a>( &'a self, path: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, Error>> + Send + 'a>>
Read a file.
None if it is not there. Read moreSource§fn put<'a>(
&'a self,
path: &'a str,
contents: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn put<'a>( &'a self, path: &'a str, contents: Bytes, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Write a file, creating any directories it needs and replacing what was
there.
Source§fn delete<'a>(
&'a self,
path: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>
fn delete<'a>( &'a self, path: &'a str, ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>
Delete a file.
true if it was there.Source§fn exists<'a>(
&'a self,
path: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>
fn exists<'a>( &'a self, path: &'a str, ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>
Whether a file exists.
Source§fn metadata<'a>(
&'a self,
path: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Option<Metadata>, Error>> + Send + 'a>>
fn metadata<'a>( &'a self, path: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<Metadata>, Error>> + Send + 'a>>
A file’s metadata, or
None.Source§fn list<'a>(
&'a self,
prefix: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Metadata>, Error>> + Send + 'a>>
fn list<'a>( &'a self, prefix: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Metadata>, Error>> + Send + 'a>>
Every file directly under
prefix, not recursing. Read moreSource§fn rename<'a>(
&'a self,
from: &'a str,
to: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
fn rename<'a>( &'a self, from: &'a str, to: &'a str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'a>>
Move a file.
Auto Trait Implementations§
impl Freeze for LocalFilesystem
impl RefUnwindSafe for LocalFilesystem
impl Send for LocalFilesystem
impl Sync for LocalFilesystem
impl Unpin for LocalFilesystem
impl UnsafeUnpin for LocalFilesystem
impl UnwindSafe for LocalFilesystem
Blanket Implementations§
impl<T> Actor for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.
Source§impl<F> FilesystemExt for Fwhere
F: Filesystem + ?Sized,
impl<F> FilesystemExt for Fwhere
F: Filesystem + ?Sized,
Source§fn get_string<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
fn get_string<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
Read a file as a string.
Source§fn put_string<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
contents: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: Sync + 'async_trait,
fn put_string<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
contents: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: Sync + 'async_trait,
Write a string.
Source§fn get_or_fail<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
fn get_or_fail<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Bytes, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
Read a file, failing with a
404 if it is absent. Read moreSource§fn size<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
fn size<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<u64>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
A file’s size.
Source§fn last_modified<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<DateTime<Utc>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
fn last_modified<'life0, 'life1, 'async_trait>(
&'life0 self,
path: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<DateTime<Utc>>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Sync + 'async_trait,
When a file was last written.
Source§fn append<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
contents: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: Sync + 'async_trait,
fn append<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
path: &'life1 str,
contents: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: Sync + 'async_trait,
Append to a file, creating it if absent. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.