Add fmt::Display for KeyLocation

Signed-off-by: Roland Vet <RlndVt@protonmail.com>
This commit is contained in:
Roland Vet 2024-02-22 21:12:36 +01:00
parent 86049a1641
commit 0ff96b2a0f

View File

@ -1,4 +1,4 @@
use std::io::{stdin, IsTerminal};
use std::{fmt, io::{stdin, IsTerminal}};
use log::{info};
use bch_bindgen::bcachefs::bch_sb_handle;
@ -47,6 +47,17 @@ impl clap::ValueEnum for KeyLocation {
}
}
impl fmt::Display for KeyLocation {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
KeyLocation::None => write!(f, "None"),
KeyLocation::Fail => write!(f, "Fail"),
KeyLocation::Wait => write!(f, "Wait"),
KeyLocation::Ask => write!(f, "Ask"),
}
}
}
fn check_for_key(key_name: &std::ffi::CStr) -> anyhow::Result<bool> {
use bch_bindgen::keyutils::{self, keyctl_search};
let key_name = key_name.to_bytes_with_nul().as_ptr() as *const _;