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>

source

pub fn exec_cmd(&self, cmd: &str) -> Result<Vec<u8>>

Execute a cmd on a remote host and get its outputs.

source

pub fn exec_exit_code(&self, cmd: &str) -> Result<i32>

Execute a cmd on a remote host and get its outputs.

source

pub fn file_stat<P: AsRef<Path>>(&self, path: P) -> Result<FileStat>

Get the attributes of a file based on the SFTP protocol

source

pub fn read_file<P: AsRef<Path>>(&self, path: P) -> Result<Vec<u8>>

Read the contents of a target file from the remote host.

source

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

source

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

source

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.

source

pub fn get_file<RP: AsRef<Path>, LP: AsRef<Path>>( &self, remote_path: RP, local_path: LP ) -> Result<()>

Download a remote file to a local path.

source

pub fn scp<LP: AsRef<Path>, RP: AsRef<Path>>( &self, local_path: LP, remote_path: RP, direction_is_out: bool ) -> Result<()>

Copy files between local host and the remote host.

Trait Implementations§

source§

impl<'a> Debug for RemoteHost<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a RemoteHostOwned> for RemoteHost<'a>

source§

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> 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<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> MaybeDebug for T
where T: Debug,