[−][src]Trait umanux::userlib::NewFromString
Try to parse a String into some Object.
Errors
if the parsing failed a UserLibError::Message
is returned containing a more detailed error message.
Required methods
pub fn new_from_string(
line: String,
position: u32
) -> Result<Self, UserLibError> where
Self: Sized,
[src]
line: String,
position: u32
) -> Result<Self, UserLibError> where
Self: Sized,
Implementations on Foreign Types
impl NewFromString for Rc<Inner>
[src]
pub fn new_from_string(
line: String,
position: u32
) -> Result<Self, UserLibError>
[src]
line: String,
position: u32
) -> Result<Self, UserLibError>
Parse a line formatted like one in /etc/group
and construct a matching Group
instance
Example
use crate::umanux::api::GroupRead; use umanux::NewFromString; let grp = umanux::Group::new_from_string( "teste:x:1002:test,teste".to_owned(), 0, ).unwrap(); assert_eq!(grp.get_groupname().unwrap(), "teste");
Errors
When parsing fails this function returns a UserLibError::Message
containing some information as to why the function failed.
Implementors
impl NewFromString for Shadow
[src]
pub fn new_from_string(
line: String,
position: u32
) -> Result<Self, UserLibError>
[src]
line: String,
position: u32
) -> Result<Self, UserLibError>
Parse a line formatted like one in /etc/shadow
and construct a matching Shadow
instance
Example
use umanux::NewFromString; let shad = umanux::Shadow::new_from_string( "test:$6$u0Hh.9WKRF1Aeu4g$XqoDyL6Re/4ZLNQCGAXlNacxCxbdigexEqzFzkOVPV5Z1H23hlenjW8ZLgq6GQtFURYwenIFpo1c.r4aW9l5S/:18260:0:99999:7:::".to_string(), 0, ).unwrap(); assert_eq!(shad.get_username(), "test");
Errors
When parsing fails this function returns a UserLibError::Message
containing some information as to why the function failed.
impl NewFromString for User
[src]
pub fn new_from_string(
line: String,
position: u32
) -> Result<Self, UserLibError> where
Self: Sized,
[src]
line: String,
position: u32
) -> Result<Self, UserLibError> where
Self: Sized,
Parse a line formatted like one in /etc/passwd
and construct a matching User
instance
Example
use crate::umanux::api::UserRead; use umanux::NewFromString; let pwd = umanux::User::new_from_string( "testuser:testpassword:1001:1001:full Name,,,,:/home/test:/bin/test".to_string(), 0).unwrap(); assert_eq!(pwd.get_username().unwrap(), "testuser");
Errors
When parsing fails this function returns a UserLibError::Message
containing some information as to why the function failed.