SshSession

Trait SshSession 

Source
pub trait SshSession: Sized {
    type Sftp: Sftp;

    // Required methods
    fn connect(opts: &SshOpts) -> RemoteResult<Self>;
    fn disconnect(&self) -> RemoteResult<()>;
    fn banner(&self) -> RemoteResult<Option<String>>;
    fn authenticated(&self) -> RemoteResult<bool>;
    fn cmd<S>(&mut self, cmd: S) -> RemoteResult<(u32, String)>
       where S: AsRef<str>;
    fn scp_recv(&self, path: &Path) -> RemoteResult<Box<dyn Read + Send>>;
    fn scp_send(
        &self,
        remote_path: &Path,
        mode: i32,
        size: u64,
        times: Option<(u64, u64)>,
    ) -> RemoteResult<Box<dyn Write + Send>>;
    fn sftp(&self) -> RemoteResult<Self::Sftp>;

    // Provided method
    fn cmd_at<S>(&mut self, cmd: S, path: &Path) -> RemoteResult<(u32, String)>
       where S: AsRef<str> { ... }
}
Expand description

SSH session trait.

Provides SSH channel functions

Required Associated Types§

Source

type Sftp: Sftp

Required Methods§

Source

fn connect(opts: &SshOpts) -> RemoteResult<Self>

Connects to the SSH server and establishes a new SshSession

Source

fn disconnect(&self) -> RemoteResult<()>

Disconnect from the server

Source

fn banner(&self) -> RemoteResult<Option<String>>

Get the SSH server banner.

Source

fn authenticated(&self) -> RemoteResult<bool>

Check if the session is authenticated.

Source

fn cmd<S>(&mut self, cmd: S) -> RemoteResult<(u32, String)>
where S: AsRef<str>,

Executes a command on the SSH server and returns the exit code and the output.

Source

fn scp_recv(&self, path: &Path) -> RemoteResult<Box<dyn Read + Send>>

Receives a file over SCP.

Returns a channel can be read from server.

Source

fn scp_send( &self, remote_path: &Path, mode: i32, size: u64, times: Option<(u64, u64)>, ) -> RemoteResult<Box<dyn Write + Send>>

Send a file over SCP.

Returns a channel which can be written to send data

Source

fn sftp(&self) -> RemoteResult<Self::Sftp>

Returns a SFTP client

Provided Methods§

Source

fn cmd_at<S>(&mut self, cmd: S, path: &Path) -> RemoteResult<(u32, String)>
where S: AsRef<str>,

Executes a command on the SSH server at a specific path and returns the exit code and the output.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SshSession for LibSsh2Session

Available on crate feature libssh2 only.
Source§

type Sftp = LibSsh2Sftp

Source§

impl SshSession for LibSshSession

Available on crate feature libssh only.
Source§

type Sftp = LibSshSftp