Expand description
A modern and idiomatic .netrc parser in Rust
This library provides a robust parser for .netrc
files, supporting machine
entries, login credentials, accounts, and macro definitions (macdef
). It
includes serialization to JSON and TOML, file I/O, and comprehensive error
handling.
The parser handles standard .netrc
file formats, validates machine names,
and supports flexible input with whitespace. Errors are reported via the
NetrcError
enum, which includes detailed parse error messages and input
context.
§Example
use netrc_parser::{Netrc, NetrcError};
let input = "machine example.com login user password pass";
let netrc = Netrc::parse_from_str(input)?;
let creds =
netrc.get("example.com").ok_or_else(|| NetrcError::NotFound("example.com".to_string()))?;
assert_eq!(creds.login, "user");
assert_eq!(creds.password, "pass");
Structs§
- Credentials
- Netrc
- Represents a complete
.netrc
file with multiple machine entries. - Netrc
Machine - Represents a single machine entry in a
.netrc
file.
Enums§
- Netrc
Error - Error types for the
netrc_parser
library.