pub struct User { /* private fields */ }
Expand description
Ssh user.
§Example
use ssh_test_server::User;
let user = User::new("user", "password");
assert_eq!(user.login(), "user");
Implementations§
Source§impl User
impl User
Sourcepub fn new<L: Into<String>, P: Into<String>>(login: L, password: P) -> Self
pub fn new<L: Into<String>, P: Into<String>>(login: L, password: P) -> Self
Create new user with password.
§Example
let u = User::new("ala", "kot");
assert_eq!(u.login(), "ala");
assert_eq!(u.password(), "kot");
Sourcepub fn new_admin<L: Into<String>, P: Into<String>>(
login: L,
password: P,
) -> Self
pub fn new_admin<L: Into<String>, P: Into<String>>( login: L, password: P, ) -> Self
Create new user with admin flag.
§Example
let u = User::new_admin("Administrator", "admin1");
assert!(u.admin());
Sourcepub fn set_admin(&mut self, admin: bool)
pub fn set_admin(&mut self, admin: bool)
Modify admin flag.
§Example
let mut u = User::new("login", "password");
assert!(!u.admin());
u.set_admin(true);
assert!(u.admin());
Sourcepub fn set_password(&mut self, new_password: &str)
pub fn set_password(&mut self, new_password: &str)
Modify user’s password.
§Example
let mut u = User::new("a", "12");
assert_eq!(u.password(), "12");
u.set_password("34");
assert_eq!(u.password(), "34");
Trait Implementations§
Auto Trait Implementations§
impl Freeze for User
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnwindSafe for User
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