Struct ruc::ssh::RemoteHost
source · pub struct RemoteHost<'a> {
pub addr: &'a str,
pub user: &'a str,
pub port: u16,
pub local_seckeys: Vec<&'a Path>,
}
Expand description
Config an instance ref.
Fields§
§addr: &'a str
The address of the remote host, eg, “8.8.8.8”.
user: &'a str
The user name of the remote host, eg, “bob”.
port: u16
The sshd listening port of the remote host.
local_seckeys: Vec<&'a Path>
Path list of the ssh secret keys(rsa/ed25519 key).
Implementations§
source§impl<'a> RemoteHost<'a>
impl<'a> RemoteHost<'a>
sourcepub fn exec_cmd(&self, cmd: &str) -> Result<Vec<u8>>
pub fn exec_cmd(&self, cmd: &str) -> Result<Vec<u8>>
Execute a cmd on a remote host and get its outputs.
sourcepub fn exec_exit_code(&self, cmd: &str) -> Result<i32>
pub fn exec_exit_code(&self, cmd: &str) -> Result<i32>
Execute a cmd on a remote host and get its outputs.
sourcepub fn file_stat<P: AsRef<Path>>(&self, path: P) -> Result<FileStat>
pub fn file_stat<P: AsRef<Path>>(&self, path: P) -> Result<FileStat>
Get the attributes of a file based on the SFTP protocol
sourcepub fn read_file<P: AsRef<Path>>(&self, path: P) -> Result<Vec<u8>>
pub fn read_file<P: AsRef<Path>>(&self, path: P) -> Result<Vec<u8>>
Read the contents of a target file from the remote host.
sourcepub fn replace_file<P: AsRef<Path>>(
&self,
remote_path: P,
contents: &[u8]
) -> Result<()>
pub fn replace_file<P: AsRef<Path>>( &self, remote_path: P, contents: &[u8] ) -> Result<()>
Fill the target file on the remote host with the local contents
sourcepub fn write_file<P: AsRef<Path>>(
&self,
remote_path: P,
contents: &[u8]
) -> Result<()>
pub fn write_file<P: AsRef<Path>>( &self, remote_path: P, contents: &[u8] ) -> Result<()>
Write(append) local contents to the target file on the remote host
sourcepub fn put_file<LP: AsRef<Path>, RP: AsRef<Path>>(
&self,
local_path: LP,
remote_path: RP
) -> Result<()>
pub fn put_file<LP: AsRef<Path>, RP: AsRef<Path>>( &self, local_path: LP, remote_path: RP ) -> Result<()>
Send a local file to the target path on the remote host.
Trait Implementations§
source§impl<'a> Debug for RemoteHost<'a>
impl<'a> Debug for RemoteHost<'a>
source§impl<'a> From<&'a RemoteHostOwned> for RemoteHost<'a>
impl<'a> From<&'a RemoteHostOwned> for RemoteHost<'a>
source§fn from(o: &'a RemoteHostOwned) -> RemoteHost<'_>
fn from(o: &'a RemoteHostOwned) -> RemoteHost<'_>
Converts to this type from the input type.
Auto Trait Implementations§
impl<'a> Freeze for RemoteHost<'a>
impl<'a> RefUnwindSafe for RemoteHost<'a>
impl<'a> Send for RemoteHost<'a>
impl<'a> Sync for RemoteHost<'a>
impl<'a> Unpin for RemoteHost<'a>
impl<'a> UnwindSafe for RemoteHost<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more