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§
Required Methods§
Sourcefn connect(opts: &SshOpts) -> RemoteResult<Self>
fn connect(opts: &SshOpts) -> RemoteResult<Self>
Connects to the SSH server and establishes a new SshSession
Sourcefn disconnect(&self) -> RemoteResult<()>
fn disconnect(&self) -> RemoteResult<()>
Disconnect from the server
Get the SSH server banner.
Sourcefn authenticated(&self) -> RemoteResult<bool>
fn authenticated(&self) -> RemoteResult<bool>
Check if the session is authenticated.
Sourcefn cmd<S>(&mut self, cmd: S) -> RemoteResult<(u32, String)>
fn cmd<S>(&mut self, cmd: S) -> RemoteResult<(u32, String)>
Executes a command on the SSH server and returns the exit code and the output.
Sourcefn scp_recv(&self, path: &Path) -> RemoteResult<Box<dyn Read + Send>>
fn scp_recv(&self, path: &Path) -> RemoteResult<Box<dyn Read + Send>>
Receives a file over SCP.
Returns a channel can be read from server.
Sourcefn scp_send(
&self,
remote_path: &Path,
mode: i32,
size: u64,
times: Option<(u64, u64)>,
) -> RemoteResult<Box<dyn Write + Send>>
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
Sourcefn sftp(&self) -> RemoteResult<Self::Sftp>
fn sftp(&self) -> RemoteResult<Self::Sftp>
Returns a SFTP client
Provided Methods§
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.
impl SshSession for LibSsh2Session
Available on crate feature
libssh2
only.Source§impl SshSession for LibSshSession
Available on crate feature libssh
only.
impl SshSession for LibSshSession
Available on crate feature
libssh
only.