| Crates.io | secretfile |
| lib.rs | secretfile |
| version | 0.1.1 |
| created_at | 2024-02-29 22:19:51.246074+00 |
| updated_at | 2025-05-22 16:04:52.152285+00 |
| description | A small library for helping with loading secrets from files including systemd service credentials support |
| homepage | |
| repository | https://github.com/icewind1991/secretfile |
| max_upload_size | |
| id | 1158241 |
| size | 7,169 |
A small library for helping with loading secrets from files including systemd service credentials support.
Load a value from a file
fn main() -> Result<(), Box<dyn std::error::Error>> {
let secret = secretfile::load("/path/to/supper/secret/file")?;
println!("{secret}");
Ok(())
}
If the provided path includes the $CREDENTIALS_DIRECTORY placeholder, it will
be replaced with the systemd service credential directory. Any trailing
whitespace will be stripped from the returned secret.
While the code is simple enough, I found myself copy-pasting it enough times that it seemed useful to put into a library.