[][src]Trait libunftp::storage::StorageBackend

pub trait StorageBackend<U: Send> {
    type File;
    type Metadata: Metadata;
    fn metadata<P: AsRef<Path>>(
        &self,
        user: &Option<U>,
        path: P
    ) -> Box<dyn Future<Item = Self::Metadata, Error = Error> + Send>;
fn list<P: AsRef<Path>>(
        &self,
        user: &Option<U>,
        path: P
    ) -> Box<dyn Stream<Item = Fileinfo<PathBuf, Self::Metadata>, Error = Error> + Send>
    where
        Self::Metadata: Metadata
;
fn get<P: AsRef<Path>>(
        &self,
        user: &Option<U>,
        path: P,
        start_pos: u64
    ) -> Box<dyn Future<Item = Self::File, Error = Error> + Send>;
fn put<P: AsRef<Path>, R: AsyncRead + Send + 'static>(
        &self,
        user: &Option<U>,
        bytes: R,
        path: P,
        start_pos: u64
    ) -> Box<dyn Future<Item = u64, Error = Error> + Send>;
fn del<P: AsRef<Path>>(
        &self,
        user: &Option<U>,
        path: P
    ) -> Box<dyn Future<Item = (), Error = Error> + Send>;
fn mkd<P: AsRef<Path>>(
        &self,
        user: &Option<U>,
        path: P
    ) -> Box<dyn Future<Item = (), Error = Error> + Send>;
fn rename<P: AsRef<Path>>(
        &self,
        user: &Option<U>,
        from: P,
        to: P
    ) -> Box<dyn Future<Item = (), Error = Error> + Send>;
fn rmd<P: AsRef<Path>>(
        &self,
        user: &Option<U>,
        path: P
    ) -> Box<dyn Future<Item = (), Error = Error> + Send>; fn supported_features(&self) -> u32 { ... }
fn list_fmt<P: AsRef<Path>>(
        &self,
        user: &Option<U>,
        path: P
    ) -> Box<dyn Future<Item = Cursor<Vec<u8>>, Error = Error> + Send>
    where
        Self::Metadata: Metadata + 'static
, { ... }
fn nlst<P: AsRef<Path>>(
        &self,
        user: &Option<U>,
        path: P
    ) -> Box<dyn Future<Item = Cursor<Vec<u8>>, Error = Error> + Send>
    where
        Self::Metadata: Metadata + 'static
, { ... } }

The Storage trait defines a common interface to different storage backends for our FTP Server, e.g. for a Filesystem or GCP buckets.

Associated Types

type File

The concrete type of the Files returned by this StorageBackend.

type Metadata: Metadata

The concrete type of the Metadata used by this StorageBackend.

Loading content...

Required methods

fn metadata<P: AsRef<Path>>(
    &self,
    user: &Option<U>,
    path: P
) -> Box<dyn Future<Item = Self::Metadata, Error = Error> + Send>

Returns the Metadata for the given file.

fn list<P: AsRef<Path>>(
    &self,
    user: &Option<U>,
    path: P
) -> Box<dyn Stream<Item = Fileinfo<PathBuf, Self::Metadata>, Error = Error> + Send> where
    Self::Metadata: Metadata

Returns the list of files in the given directory.

fn get<P: AsRef<Path>>(
    &self,
    user: &Option<U>,
    path: P,
    start_pos: u64
) -> Box<dyn Future<Item = Self::File, Error = Error> + Send>

Returns the content of the given file from offset start_pos. The starting position can 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.

fn put<P: AsRef<Path>, R: AsyncRead + Send + 'static>(
    &self,
    user: &Option<U>,
    bytes: R,
    path: P,
    start_pos: u64
) -> Box<dyn Future<Item = u64, Error = Error> + Send>

Write the given bytes to the given file starting at offset

fn del<P: AsRef<Path>>(
    &self,
    user: &Option<U>,
    path: P
) -> Box<dyn Future<Item = (), Error = Error> + Send>

Delete the given file.

fn mkd<P: AsRef<Path>>(
    &self,
    user: &Option<U>,
    path: P
) -> Box<dyn Future<Item = (), Error = Error> + Send>

Create the given directory.

fn rename<P: AsRef<Path>>(
    &self,
    user: &Option<U>,
    from: P,
    to: P
) -> Box<dyn Future<Item = (), Error = Error> + Send>

Rename the given file to the given filename.

fn rmd<P: AsRef<Path>>(
    &self,
    user: &Option<U>,
    path: P
) -> Box<dyn Future<Item = (), Error = Error> + Send>

Delete the given directory.

Loading content...

Provided methods

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.

fn list_fmt<P: AsRef<Path>>(
    &self,
    user: &Option<U>,
    path: P
) -> Box<dyn Future<Item = Cursor<Vec<u8>>, Error = Error> + Send> where
    Self::Metadata: Metadata + 'static, 

Returns some bytes that make up a directory listing that can immediately be sent to the client.

fn nlst<P: AsRef<Path>>(
    &self,
    user: &Option<U>,
    path: P
) -> Box<dyn Future<Item = Cursor<Vec<u8>>, Error = Error> + Send> where
    Self::Metadata: Metadata + 'static, 

Returns some bytes that make up a NLST directory listing (only the basename) that can immediately be sent to the client.

Loading content...

Implementors

impl<U: Send> StorageBackend<U> for Filesystem[src]

type File = File

type Metadata = Metadata

Loading content...