Skip to main content

SshClientTrait

Trait SshClientTrait 

Source
pub trait SshClientTrait:
    Send
    + Sync
    + 'static {
    // Required methods
    fn connect<'async_trait>(
        cfg: ConnectionConfig,
    ) -> Pin<Box<dyn Future<Output = Result<Box<Self>, SshCliError>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait;
    fn run_command<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        cmd: &'life1 str,
        max_chars: usize,
        stdin_data: Option<Vec<u8>>,
    ) -> Pin<Box<dyn Future<Output = Result<ExecutionOutput, SshCliError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn upload<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        local: &'life1 Path,
        remote: &'life2 Path,
    ) -> Pin<Box<dyn Future<Output = Result<TransferResult, SshCliError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn download<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        remote: &'life1 Path,
        local: &'life2 Path,
    ) -> Pin<Box<dyn Future<Output = Result<TransferResult, SshCliError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn open_tunnel_channel<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        remote_host: &'life1 str,
        remote_port: u16,
        endereco_origem: &'life2 str,
        porta_origem: u16,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn TunnelChannel>, SshCliError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn disconnect<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), SshCliError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

SSH client trait allowing a real (russh) or mock implementation for tests.

This trait abstracts SSH connection operations to allow unit tests without needing a real network connection.

Required Methods§

Source

fn connect<'async_trait>( cfg: ConnectionConfig, ) -> Pin<Box<dyn Future<Output = Result<Box<Self>, SshCliError>> + Send + 'async_trait>>
where Self: Sized + 'async_trait,

Connects to an SSH server and authenticates with the provided credentials.

Source

fn run_command<'life0, 'life1, 'async_trait>( &'life0 mut self, cmd: &'life1 str, max_chars: usize, stdin_data: Option<Vec<u8>>, ) -> Pin<Box<dyn Future<Output = Result<ExecutionOutput, SshCliError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Runs a remote shell command and returns the captured output.

stdin_data, if present, is written to the channel after exec and before the loop de leitura (GAP-SSH-SEC-001: password sudo/su fora da argv remota).

Source

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

Faz upload de um file local para o servidor remoto via SCP.

Source

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

Faz download de um file remoto para o sistema local via SCP.

Source

fn open_tunnel_channel<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, remote_host: &'life1 str, remote_port: u16, endereco_origem: &'life2 str, porta_origem: u16, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn TunnelChannel>, SshCliError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Abre um channel direct-tcpip para forwarding de tunnel.

Source

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

Cleanly closes the SSH connection.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl SshClientTrait for SshClient

Available on crate feature ssh-real only.