secretfile 0.1.1

A small library for helping with loading secrets from files including systemd service credentials support
Documentation
  • Coverage
  • 14.29%
    1 out of 7 items documented0 out of 2 items with examples
  • Size
  • Source code size: 6.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.36 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • icewind1991/secretfile
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • icewind1991

Secretfile

A small library for helping with loading secrets from files including systemd service credentials support.

Usage

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.

Why make this a library?

While the code is simple enough, I found myself copy-pasting it enough times that it seemed useful to put into a library.