Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

Unified client over SMB / FTP / SFTP.

Holds a type-erased backend (Box<dyn RemoteFileSystem>), so trait methods forward in one line — no per-protocol match boilerplate.

Backends are gated by Cargo features: smb, ftp, sftp.

Implementations§

Source§

impl Client

Source

pub async fn connect_with(config: &Config) -> Result<Self>

Create a client from a generic config and connect.

Source

pub fn protocol(&self) -> Protocol

Active protocol of this client.

Source

pub fn as_fs(&self) -> &dyn RemoteFileSystem

Borrow the underlying filesystem trait object.

Source

pub fn as_fs_mut(&mut self) -> &mut dyn RemoteFileSystem

Mutably borrow the underlying filesystem trait object.

Trait Implementations§

Source§

impl Deref for Client

Source§

type Target = dyn RemoteFileSystem

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Client

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl RemoteFileSystem for Client

Source§

fn connect<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Connect to the remote server.
Source§

fn disconnect<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Disconnect from the remote server.
Source§

fn is_connected(&self) -> bool

Whether the client is currently connected.
Source§

fn list<'life0, 'life1, 'async_trait>( &'life0 mut self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<FileEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List entries under path.
Source§

fn metadata<'life0, 'life1, 'async_trait>( &'life0 mut self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<FileMeta>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get metadata for path.
Source§

fn exists<'life0, 'life1, 'async_trait>( &'life0 mut self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check whether path exists.
Source§

fn mkdir<'life0, 'life1, 'async_trait>( &'life0 mut self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a directory at path.
Source§

fn mkdir_all<'life0, 'life1, 'async_trait>( &'life0 mut self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create directories recursively.
Source§

fn rmdir<'life0, 'life1, 'async_trait>( &'life0 mut self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove an empty directory.
Source§

fn remove_file<'life0, 'life1, 'async_trait>( &'life0 mut self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a file.
Source§

fn remove<'life0, 'life1, 'async_trait>( &'life0 mut self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a file or directory recursively.
Source§

fn rename<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, from: &'life1 str, to: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Rename / move a path.
Source§

fn read<'life0, 'life1, 'async_trait>( &'life0 mut self, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read entire file into memory.
Source§

fn write<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, path: &'life1 str, data: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Write entire file from memory.
Source§

fn download<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, remote: &'life1 str, local: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Download remote file to local path.
Source§

fn upload<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, local: &'life1 Path, remote: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Upload local file to remote path.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl !Sync for Client

§

impl !UnwindSafe for Client

§

impl Freeze for Client

§

impl Send for Client

§

impl Unpin for Client

§

impl UnsafeUnpin for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.