pub trait GuardedFileSystem<C>:
Send
+ Sync
+ DynClone{
Show 14 methods
// Required methods
fn open<'a>(
&'a self,
path: &'a DavPath,
options: OpenOptions,
credentials: &'a C,
) -> FsFuture<'a, Box<dyn DavFile>>;
fn read_dir<'a>(
&'a self,
path: &'a DavPath,
meta: ReadDirMeta,
credentials: &'a C,
) -> FsFuture<'a, FsStream<Box<dyn DavDirEntry>>>;
fn metadata<'a>(
&'a self,
path: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, Box<dyn DavMetaData>>;
// Provided methods
fn symlink_metadata<'a>(
&'a self,
path: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, Box<dyn DavMetaData>> { ... }
fn create_dir<'a>(
&'a self,
path: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, ()> { ... }
fn remove_dir<'a>(
&'a self,
path: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, ()> { ... }
fn remove_file<'a>(
&'a self,
path: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, ()> { ... }
fn rename<'a>(
&'a self,
from: &'a DavPath,
to: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, ()> { ... }
fn copy<'a>(
&'a self,
from: &'a DavPath,
to: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, ()> { ... }
fn have_props<'a>(
&'a self,
path: &'a DavPath,
credentials: &'a C,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>> { ... }
fn patch_props<'a>(
&'a self,
path: &'a DavPath,
patch: Vec<(bool, DavProp)>,
credentials: &'a C,
) -> FsFuture<'a, Vec<(StatusCode, DavProp)>> { ... }
fn get_props<'a>(
&'a self,
path: &'a DavPath,
do_content: bool,
credentials: &'a C,
) -> FsFuture<'a, Vec<DavProp>> { ... }
fn get_prop<'a>(
&'a self,
path: &'a DavPath,
prop: DavProp,
credentials: &'a C,
) -> FsFuture<'a, Vec<u8>> { ... }
fn get_quota<'a>(
&'a self,
credentials: &'a C,
) -> FsFuture<'a, (u64, Option<u64>)> { ... }
}
Expand description
File system with access control. Type parameter C
(credentials) represents
the authentication and authorization information required for accessing the file system.
This can include various forms of credentials such as:
- auth tokens,
- login and password hash combinations,
- encryption keys.
Additionally, it may encapsulate context, scope or metadata related to the request, such as:
- a set of file system permissions granted to a user,
- regionally-defined access scope.
All HTTP security considerations also apply to WebDAV, so you should follow the same authorization best practices as you would for regular HTTP server.
If credentials C
include a username, you may want
to specify it as principal
to the DavHandler
builder so that the locks user requests
have a known owner.
For file systems without access control, implement simpler DavFileSystem
trait,
for which there’s a blanket implementation of GuardedFileSystem<()>
.
See also the auth example.
Required Methods§
Sourcefn open<'a>(
&'a self,
path: &'a DavPath,
options: OpenOptions,
credentials: &'a C,
) -> FsFuture<'a, Box<dyn DavFile>>
fn open<'a>( &'a self, path: &'a DavPath, options: OpenOptions, credentials: &'a C, ) -> FsFuture<'a, Box<dyn DavFile>>
Open a file.
Sourcefn read_dir<'a>(
&'a self,
path: &'a DavPath,
meta: ReadDirMeta,
credentials: &'a C,
) -> FsFuture<'a, FsStream<Box<dyn DavDirEntry>>>
fn read_dir<'a>( &'a self, path: &'a DavPath, meta: ReadDirMeta, credentials: &'a C, ) -> FsFuture<'a, FsStream<Box<dyn DavDirEntry>>>
Lists entries within a directory.
Provided Methods§
Sourcefn symlink_metadata<'a>(
&'a self,
path: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, Box<dyn DavMetaData>>
fn symlink_metadata<'a>( &'a self, path: &'a DavPath, credentials: &'a C, ) -> FsFuture<'a, Box<dyn DavMetaData>>
Return the metadata of a file, directory or symbolic link.
Differs from metadata
that if the path is a symbolic link,
it return the metadata for the link itself, not for the thing
it points to.
The default implementation returns FsError::NotImplemented
.
Sourcefn create_dir<'a>(
&'a self,
path: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, ()>
fn create_dir<'a>( &'a self, path: &'a DavPath, credentials: &'a C, ) -> FsFuture<'a, ()>
Create a directory.
The default implementation returns FsError::NotImplemented
.
Sourcefn remove_dir<'a>(
&'a self,
path: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, ()>
fn remove_dir<'a>( &'a self, path: &'a DavPath, credentials: &'a C, ) -> FsFuture<'a, ()>
Remove a directory.
The default implementation returns FsError::NotImplemented
.
Sourcefn remove_file<'a>(
&'a self,
path: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, ()>
fn remove_file<'a>( &'a self, path: &'a DavPath, credentials: &'a C, ) -> FsFuture<'a, ()>
Remove a file.
The default implementation returns FsError::NotImplemented
.
Sourcefn rename<'a>(
&'a self,
from: &'a DavPath,
to: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, ()>
fn rename<'a>( &'a self, from: &'a DavPath, to: &'a DavPath, credentials: &'a C, ) -> FsFuture<'a, ()>
Rename a file or directory.
Source and destination must be the same type (file/dir). If the destination already exists and is a file, it should be replaced. If it is a directory it should give an error.
The default implementation returns FsError::NotImplemented
.
Sourcefn copy<'a>(
&'a self,
from: &'a DavPath,
to: &'a DavPath,
credentials: &'a C,
) -> FsFuture<'a, ()>
fn copy<'a>( &'a self, from: &'a DavPath, to: &'a DavPath, credentials: &'a C, ) -> FsFuture<'a, ()>
Copy a file.
Should also copy the DAV properties, if properties are implemented.
The default implementation returns FsError::NotImplemented
.
Sourcefn have_props<'a>(
&'a self,
path: &'a DavPath,
credentials: &'a C,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>
fn have_props<'a>( &'a self, path: &'a DavPath, credentials: &'a C, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>
Indicator that tells if this filesystem driver supports DAV properties.
The default implementation returns false
.
Sourcefn patch_props<'a>(
&'a self,
path: &'a DavPath,
patch: Vec<(bool, DavProp)>,
credentials: &'a C,
) -> FsFuture<'a, Vec<(StatusCode, DavProp)>>
fn patch_props<'a>( &'a self, path: &'a DavPath, patch: Vec<(bool, DavProp)>, credentials: &'a C, ) -> FsFuture<'a, Vec<(StatusCode, DavProp)>>
Patch the DAV properties of a node (add/remove props).
The default implementation returns FsError::NotImplemented
.
Sourcefn get_props<'a>(
&'a self,
path: &'a DavPath,
do_content: bool,
credentials: &'a C,
) -> FsFuture<'a, Vec<DavProp>>
fn get_props<'a>( &'a self, path: &'a DavPath, do_content: bool, credentials: &'a C, ) -> FsFuture<'a, Vec<DavProp>>
List/get the DAV properties of a node.
The default implementation returns FsError::NotImplemented
.
Sourcefn get_prop<'a>(
&'a self,
path: &'a DavPath,
prop: DavProp,
credentials: &'a C,
) -> FsFuture<'a, Vec<u8>>
fn get_prop<'a>( &'a self, path: &'a DavPath, prop: DavProp, credentials: &'a C, ) -> FsFuture<'a, Vec<u8>>
Get one specific named property of a node.
The default implementation returns FsError::NotImplemented
.
Sourcefn get_quota<'a>(
&'a self,
credentials: &'a C,
) -> FsFuture<'a, (u64, Option<u64>)>
fn get_quota<'a>( &'a self, credentials: &'a C, ) -> FsFuture<'a, (u64, Option<u64>)>
Get quota of this filesystem (used/total space).
The first value returned is the amount of space used, the second optional value is the total amount of space (used + available).
The default implementation returns FsError::NotImplemented
.