myloginrs

Build status

Read and parse MySQL's .mylogin.cnf file.

Usage

Add myloginrs to Cargo.toml:

toml [dependencies] myloginrs = "0.1"

Example

To get a HashMap of login info for "client" just use the parse function:

```rust let filepath = PathBuf::from( "tests/testmylogin.cnf", );

let clientinfo = myloginrs::parse("client", Some(&filepath)); ```

Then you can use that HashMap with an OptsBuilder or other structs from the mysql:

```rust let opts = OptsBuilder::new() .iporhostname(Some(&clientinfo["host"])) .tcpport(u16::fromstrradix(&clientinfo["port"], 10)?) .user(Some(&clientinfo["user"])) .pass(Some(&client_info["password"]));

let _conn = Conn::new(opts); ```

If you would rather get a String that contains the whole file, use read:

```rust let mylogin_plaintext = myloginrs::read(None);

println!("{}", mylogin_plaintext); ```

This second example passes None as the path to use the default .mylogin.cnf location (%APPDATA%\MySQL\.mylogin.cnf on windows or ~/.mylogin.cnf on everything else).

other stuff

Thanks to * github.com/PyMySQL and * github.com/ocelot-inc for doing all the hard work and from whom I port.

Pull requests welcome. :)