pub struct FileFetch { /* private fields */ }Available on crate feature
fetcher-file only.Expand description
KeyFetch implementation that reads bytes from a file on disk.
By default Unix permission bits stricter than 0o600 are rejected; call
FileFetch::allow_loose_perms to disable that check (not recommended
outside of tests).
§Examples
use key_vault::{FetchContext, FileFetch, KeyFetch};
// Assume /etc/myapp/key.bin is mode 0600 and contains 32 bytes.
let fetcher = FileFetch::new("/etc/myapp/key.bin");
let raw = fetcher.fetch(&FetchContext::new("primary"))?;
assert_eq!(raw.len(), 32);Implementations§
Source§impl FileFetch
impl FileFetch
Sourcepub fn new(path: impl Into<PathBuf>) -> Self
pub fn new(path: impl Into<PathBuf>) -> Self
Construct a fetcher that reads the file at path. Strict Unix
permission checking is enabled by default.
Sourcepub fn allow_loose_perms(self) -> Self
pub fn allow_loose_perms(self) -> Self
Disable strict Unix permission checking.
Useful for test fixtures and containers where the user controlling
the file is the same as the process user but the file may have
been created with 0o644. Do not disable strict perms in
production deployments where multiple users share the host.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileFetch
impl RefUnwindSafe for FileFetch
impl Send for FileFetch
impl Sync for FileFetch
impl Unpin for FileFetch
impl UnsafeUnpin for FileFetch
impl UnwindSafe for FileFetch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more