Crates.io | credent_fs_model |
lib.rs | credent_fs_model |
version | 0.4.1 |
source | src |
created_at | 2021-03-20 02:54:04.216644 |
updated_at | 2021-04-04 23:08:58.308199 |
description | Reads / Writes credentials from / to disk. |
homepage | |
repository | https://github.com/azriel91/credent |
max_upload_size | |
id | 371238 |
size | 7,246 |
Manages ~/.config/<app>/credentials
.
Add the following to Cargo.toml:
credent = { version = "0.4.1", features = ["backend-smol"] } # or "backend-tokio"
Example code:
use credent::{
cli::CredentialsCliReader,
fs::{model::AppName, CredentialsFile, CredentialsFileStorer},
model::Credentials,
};
/// Application name
const CREDENT: AppName<'_> = AppName("credent");
fn main() -> Result<(), Box<dyn std::error::Error>> {
smol::run(async {
let credentials = CredentialsCliReader::<Credentials>::read_from_tty().await?;
println!("credentials: {}", credentials);
CredentialsFileStorer::<Credentials>::store(CREDENT, &credentials).await?;
println!(
"credentials written to: {}",
CredentialsFile::<Credentials>::path(CREDENT)?.display()
);
Result::<(), Box<dyn std::error::Error>>::Ok(())
})
}
More examples can be seen in the examples.
# Use either "backend-smol" or "backend-tokio"
cargo run --features "backend-smol" --example simple
cargo run --features "backend-smol" --example demo
cargo run --features "backend-smol" --example profiles
cargo run --features "backend-smol" --example profiles -- --profile development
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.