1 unstable release
0.1.0 | Mar 21, 2024 |
---|
#658 in Authentication
23KB
577 lines
netrc_util
A simple libary for parsing netrc files.
Usage
use netrc_util::{Host, NetrcParser};
fn main() {
let netrc_content = "machine sample.test login user password pass";
let host = Host::parse("sample.test").unwrap();
let entry = NetrcParser::new(netrc_content).entry_for_host(&host).unwrap().unwrap();
assert_eq!(entry.login(), Some("login"));
assert_eq!(entry.password(), Some("pass"));
}
lib.rs
:
netrc_util
A simple libary for parsing netrc files.
Usage
use netrc_util::{Host, NetrcParser};
let netrc_content = "machine sample.test login user password pass";
let host = Host::parse("sample.test").unwrap();
let entry = NetrcParser::new(netrc_content.as_bytes())
.entry_for_host(&host)
.unwrap()
.unwrap();
assert_eq!(entry.login(), Some("user".to_string()).as_ref());
assert_eq!(entry.password(), "pass");
Dependencies
~3–4.5MB
~76K SLoC