[−][src]Struct ssh_host::SshHost
this structure is used for storing the hostdata for easier storrage of the related information
The name
field is the name of the remote.
The address
field store the address of the remote hosts.
The port
is for the remote port that ssh must use to connect.
The private_key
is the path to the private_key to use.
Methods
impl SshHost
[src]
pub fn new(
name: String,
address: String,
user: Option<String>,
port: Option<i64>,
private_key: Option<PathBuf>
) -> SshHost
[src]
name: String,
address: String,
user: Option<String>,
port: Option<i64>,
private_key: Option<PathBuf>
) -> SshHost
return a new struct SshHost
Examples
use std::path::PathBuf; let val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), Some(String::from("user")), None, Some(PathBuf::from("private_key"))); assert_eq!(val.get_name(), String::from("hello")); assert_eq!(val.get_address(), String::from("127.0.0.1")); assert_eq!(val.get_user(), String::from("user")); assert_eq!(val.get_port(), 22); assert_eq!(val.get_private_key().unwrap(), PathBuf::from("private_key")); assert_eq!(val.is_reachable(), true); assert_eq!(val.get_url().unwrap(), String::from("127.0.0.1:22"));
pub fn get_name(&self) -> String
[src]
return the name of the remote
Examples
let val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), None, None, None); assert_eq!(val.get_name(), String::from("hello"));
pub fn set_name(&mut self, new_name: String)
[src]
set the name of the remote
Examples
let mut val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), None, None, None); assert_eq!(val.get_name(), String::from("hello")); val.set_name(String::from("foobar")); assert_eq!(val.get_name(), String::from("foobar"));
pub fn get_address(&self) -> String
[src]
return the address of the remote
Examples
let val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), None, None, None); assert_eq!(val.get_address(), String::from("127.0.0.1"));
pub fn set_address(&mut self, new_address: String)
[src]
set the address of the remote
Examples
let mut val = SshHost::new(String::from("hello"), String::from("127.0.0.2"), None, None, None); assert_eq!(val.get_address(), String::from("127.0.0.2")); val.set_address(String::from("127.0.0.1")); assert_eq!(val.get_address(), String::from("127.0.0.1"));
pub fn get_user(&self) -> String
[src]
return the user of the remote
Examples
let val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), Some(String::from("user")), None, None); assert_eq!(val.get_user(), String::from("user"));
pub fn set_user(&mut self, new_user: String)
[src]
set the address of the remote
Examples
let mut val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), Some(String::from("user")), None, None); assert_eq!(val.get_user(), String::from("user")); val.set_user(String::from("root")); assert_eq!(val.get_user(), String::from("root"));
pub fn get_port(&self) -> i64
[src]
return the port of the remote
Examples
let val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), None, Some(2222), None); assert_eq!(val.get_port(), 2222);
pub fn set_port(&mut self, new_port: i64)
[src]
set the port of the remote
Examples
let mut val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), None, None, None); assert_eq!(val.get_port(), 22); val.set_port(2222); assert_eq!(val.get_port(), 2222);
pub fn get_private_key(&self) -> Option<PathBuf>
[src]
return the private key file of the remote
Examples
use std::path::PathBuf; let val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), None, None, Some(PathBuf::from("private_key"))); assert_eq!(val.get_private_key().unwrap(), PathBuf::from("private_key"));
pub fn set_private_key(&mut self, new_key: Option<PathBuf>)
[src]
set the the private_key of the remote
Examples
use std::path::PathBuf; let mut val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), None, None, Some(PathBuf::from("private_key"))); assert_eq!(val.get_private_key().unwrap(), PathBuf::from("private_key")); val.set_private_key(Some(PathBuf::from("private_key_2"))); assert_eq!(val.get_private_key().unwrap(), PathBuf::from("private_key_2"));
pub fn is_reachable(&self) -> bool
[src]
return if the remote hosts is available or not
Examples
use std::path::PathBuf; let val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), None, None, None); assert_eq!(val.is_reachable(), true);
pub fn set_reachable(&mut self, new_val: bool)
[src]
set the remote value
Examples
use std::path::PathBuf; let mut val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), None, None, None); assert_eq!(val.is_reachable(), true); val.set_reachable(false); assert_eq!(val.is_reachable(), false);
pub fn get_url(&self) -> Result<String, &str>
[src]
return the url of the hosts
It will be in the form of address:port
like 127.0.0.1:22
Examples
use std::path::PathBuf; let val = SshHost::new(String::from("hello"), String::from("127.0.0.1"), None, Some(2222), None); assert_eq!(val.get_url().unwrap(), String::from("127.0.0.1:2222"));
Auto Trait Implementations
impl Send for SshHost
impl Sync for SshHost
impl Unpin for SshHost
impl UnwindSafe for SshHost
impl RefUnwindSafe for SshHost
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,