Struct libsystemd::credentials::CredentialsLoader
source · pub struct CredentialsLoader { /* private fields */ }
Expand description
Credential loader for units.
Credentials are read by systemd on unit startup and exported by their ID.
Note: only the user associated with the unit and the superuser may access credentials.
More documentation: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Credentials
Implementations§
source§impl CredentialsLoader
impl CredentialsLoader
sourcepub fn path_from_env() -> Option<PathBuf>
pub fn path_from_env() -> Option<PathBuf>
Return the location of the credentials directory, if any.
sourcepub fn get(&self, id: impl AsRef<str>) -> Result<File, SdError>
pub fn get(&self, id: impl AsRef<str>) -> Result<File, SdError>
Get credential by ID.
Examples
use libsystemd::credentials::CredentialsLoader;
let loader = CredentialsLoader::open()?;
let token = loader.get("token")?;
let token_metadata = token.metadata()?;
println!("token size: {}", token_metadata.len());
sourcepub fn iter(&self) -> Result<ReadDir, SdError>
pub fn iter(&self) -> Result<ReadDir, SdError>
Return an iterator over all existing credentials.
Examples
use libsystemd::credentials::CredentialsLoader;
let loader = CredentialsLoader::open()?;
for entry in loader.iter()? {
let credential = entry?;
println!("Credential ID: {}", credential.file_name().to_string_lossy());
}
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for CredentialsLoader
impl Send for CredentialsLoader
impl !Sync for CredentialsLoader
impl Unpin for CredentialsLoader
impl UnwindSafe for CredentialsLoader
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