Trait libunftp::storage::StorageBackend
source · pub trait StorageBackend<User: UserDetail>: Send + Sync + Debug {
type Metadata: Metadata + Sync + Send;
Show 16 methods
fn metadata<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Self::Metadata>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Vec<Fileinfo<PathBuf, Self::Metadata>>>> + Send + 'async_trait>>
where
<Self as StorageBackend<User>>::Metadata: Metadata,
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P,
start_pos: u64
) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncRead + Send + Sync + Unpin>>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn put<'life0, 'life1, 'async_trait, P, R>(
&'life0 self,
user: &'life1 User,
input: R,
path: P,
start_pos: u64
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send + Debug,
R: 'async_trait + AsyncRead + Send + Sync + Unpin + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn del<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn mkd<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn rename<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
from: P,
to: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn rmd<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn cwd<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn name(&self) -> &str { ... }
fn supported_features(&self) -> u32 { ... }
fn md5<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
{ ... }
fn list_fmt<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Cursor<Vec<u8>>, Error>> + Send + 'async_trait>>
where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self::Metadata: Metadata + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
{ ... }
fn list_vec<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>
where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self::Metadata: Metadata + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
{ ... }
fn nlst<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Cursor<Vec<u8>>, Error>> + Send + 'async_trait>>
where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self::Metadata: Metadata + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
{ ... }
fn get_into<'a, 'life0, 'life1, 'async_trait, P, W>(
&'life0 self,
user: &'life1 User,
path: P,
start_pos: u64,
output: &'a mut W
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where
W: AsyncWrite + Unpin + Sync + Send + 'async_trait + ?Sized,
P: AsRef<Path> + Send + Debug + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
{ ... }
}
Expand description
The StorageBackend
trait can be implemented to create custom FTP virtual file systems. Once
implemented it needs to be registered with the Server
on construction.
Required Associated Types§
Required Methods§
sourcefn metadata<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Self::Metadata>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn metadata<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Self::Metadata>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the Metadata
for the given file.
sourcefn list<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Vec<Fileinfo<PathBuf, Self::Metadata>>>> + Send + 'async_trait>>where
<Self as StorageBackend<User>>::Metadata: Metadata,
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Vec<Fileinfo<PathBuf, Self::Metadata>>>> + Send + 'async_trait>>where
<Self as StorageBackend<User>>::Metadata: Metadata,
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the list of files in the given directory.
sourcefn get<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P,
start_pos: u64
) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncRead + Send + Sync + Unpin>>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P,
start_pos: u64
) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncRead + Send + Sync + Unpin>>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the content of the given file from offset start_pos. The starting position will only be greater than zero if the storage back-end implementation advertises to support partial reads through the supported_features method i.e. the result from supported_features yield 1 if a logical and operation is applied with FEATURE_RESTART.
sourcefn put<'life0, 'life1, 'async_trait, P, R>(
&'life0 self,
user: &'life1 User,
input: R,
path: P,
start_pos: u64
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
R: 'async_trait + AsyncRead + Send + Sync + Unpin + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put<'life0, 'life1, 'async_trait, P, R>(
&'life0 self,
user: &'life1 User,
input: R,
path: P,
start_pos: u64
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
R: 'async_trait + AsyncRead + Send + Sync + Unpin + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Writes bytes from the given reader to the specified path starting at offset start_pos in the file
sourcefn del<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn del<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deletes the file at the given path.
sourcefn mkd<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mkd<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Creates the given directory.
sourcefn rename<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
from: P,
to: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn rename<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
from: P,
to: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Renames the given file to the given new filename.
sourcefn rmd<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn rmd<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deletes the given directory.
sourcefn cwd<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cwd<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
P: 'async_trait + AsRef<Path> + Send + Debug,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Changes the working directory to the given path.
Provided Methods§
sourcefn name(&self) -> &str
fn name(&self) -> &str
Implement to set the name of the storage back-end. By default it returns the type signature.
sourcefn supported_features(&self) -> u32
fn supported_features(&self) -> u32
Tells which optional features are supported by the storage back-end Return a value with bits set according to the FEATURE_* constants.
sourcefn md5<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn md5<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the MD5 hash for the given file.
Whether or not you want to implement the md5 method yourself, or you want to let your StorageBackend make use of the below default implementation, you must still explicitly enable the feature via the supported_features method.
When implementing, use the lower case 2-digit hexadecimal
format (like the output of the md5sum
command)
sourcefn list_fmt<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Cursor<Vec<u8>>, Error>> + Send + 'async_trait>>where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self::Metadata: Metadata + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_fmt<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Cursor<Vec<u8>>, Error>> + Send + 'async_trait>>where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self::Metadata: Metadata + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns some bytes that make up a directory listing that can immediately be sent to the client.
sourcefn list_vec<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self::Metadata: Metadata + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_vec<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self::Metadata: Metadata + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns directory listing as a vec of strings used for multi line response in the control channel.
sourcefn nlst<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Cursor<Vec<u8>>, Error>> + Send + 'async_trait>>where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self::Metadata: Metadata + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn nlst<'life0, 'life1, 'async_trait, P>(
&'life0 self,
user: &'life1 User,
path: P
) -> Pin<Box<dyn Future<Output = Result<Cursor<Vec<u8>>, Error>> + Send + 'async_trait>>where
P: AsRef<Path> + Send + Debug + 'async_trait,
Self::Metadata: Metadata + 'static,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns some bytes that make up a NLST directory listing (only the basename) that can immediately be sent to the client.
sourcefn get_into<'a, 'life0, 'life1, 'async_trait, P, W>(
&'life0 self,
user: &'life1 User,
path: P,
start_pos: u64,
output: &'a mut W
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
W: AsyncWrite + Unpin + Sync + Send + 'async_trait + ?Sized,
P: AsRef<Path> + Send + Debug + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_into<'a, 'life0, 'life1, 'async_trait, P, W>(
&'life0 self,
user: &'life1 User,
path: P,
start_pos: u64,
output: &'a mut W
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
W: AsyncWrite + Unpin + Sync + Send + 'async_trait + ?Sized,
P: AsRef<Path> + Send + Debug + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Gets the content of the given FTP file from offset start_pos file by copying it to the output writer. The starting position will only be greater than zero if the storage back-end implementation advertises to support partial reads through the supported_features method i.e. the result from supported_features yield 1 if a logical and operation is applied with FEATURE_RESTART.