pub struct NvList { /* private fields */ }Expand description
An ordered list of name-value pairs, converted from an illumos nvlist.
Implementations§
Source§impl NvList
impl NvList
Sourcepub unsafe fn from_raw(nvl: *mut nvlist) -> Result<NvList, NvError>
pub unsafe fn from_raw(nvl: *mut nvlist) -> Result<NvList, NvError>
Convert a raw nvlist_t * into an owned NvList.
Pair names and string values are converted from C strings using
lossy UTF-8 conversion: any bytes that are not valid UTF-8 are
replaced with U+FFFD (\u{FFFD}). This means a lookup() call
will not match the original name if it contained non-UTF-8 bytes.
§Safety
nvl must be a valid, non-null pointer to an nvlist. The nvlist is
borrowed - the caller retains ownership and is responsible for
freeing it.
Sourcepub fn lookup(&self, name: &str) -> Option<&NvValue>
pub fn lookup(&self, name: &str) -> Option<&NvValue>
Look up a value by name.
Examples found in repository?
examples/list_modules.rs (line 38)
3fn main() {
4 let adm = FmdAdm::open().expect("failed to open fmd adm handle");
5
6 println!("=== FMD Modules ===");
7 let modules = adm.modules().expect("failed to list modules");
8 for m in &modules {
9 println!(
10 " {} v{} - {}{}",
11 m.name,
12 m.version,
13 m.description,
14 if m.failed { " [FAILED]" } else { "" },
15 );
16 }
17 println!("({} modules total)", modules.len());
18
19 println!("\n=== Faulty Resources ===");
20 let resources = adm.resources(true).expect("failed to list resources");
21 if resources.is_empty() {
22 println!(" (none)");
23 } else {
24 for r in &resources {
25 println!(" {} (case {})", r.fmri, r.uuid);
26 }
27 }
28
29 println!("\n=== Cases ===");
30 let cases = adm.cases(None).expect("failed to list cases");
31 if cases.is_empty() {
32 println!(" (none)");
33 } else {
34 for c in &cases {
35 let severity = c
36 .event
37 .as_ref()
38 .and_then(|e| e.lookup("severity"))
39 .and_then(|v| match v {
40 NvValue::String(s) => Some(s.as_str()),
41 _ => None,
42 })
43 .unwrap_or("unknown");
44 println!(" {} - {} (severity: {})", c.uuid, c.code, severity);
45 }
46 }
47}Trait Implementations§
Source§impl<'a> IntoIterator for &'a NvList
impl<'a> IntoIterator for &'a NvList
Source§impl IntoIterator for NvList
impl IntoIterator for NvList
impl StructuralPartialEq for NvList
Auto Trait Implementations§
impl Freeze for NvList
impl RefUnwindSafe for NvList
impl Send for NvList
impl Sync for NvList
impl Unpin for NvList
impl UnsafeUnpin for NvList
impl UnwindSafe for NvList
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