Skip to main content

CollateralManager

Struct CollateralManager 

Source
pub struct CollateralManager<T: CollateralTree> {
    pub target_info: HashMap<u32, TargetInfo>,
    /* private fields */
}
Available on crate feature collateral_manager only.
Expand description

Manages the product-specific collateral files required to decode the Crash Log records.

Fields§

§target_info: HashMap<u32, TargetInfo>

Maps the Crash Log product IDs into a data structure that stores various information about the associated product.

Implementations§

Source§

impl CollateralManager<EmbeddedTree>

Source

pub fn embedded_tree() -> Result<Self, Error>

Available on crate feature embedded_collateral_tree only.

Creates a CollateralManager that uses a collateral tree embedded in the library. This allows the collateral items to be used without requiring any file system access. The collateral items will be loaded in memory alongside the library code.

§Examples
use intel_crashlog::prelude::*;

let collateral_manager = CollateralManager::embedded_tree();
assert!(collateral_manager.is_ok());
Source§

impl CollateralManager<FileSystemTree>

Source

pub fn file_system_tree(root: &Path) -> Result<Self, Error>

Available on crate feature fs_collateral_tree only.

Creates a CollateralManager that uses a collateral tree stored in the file system. The collateral items will be loaded at run-time from the collateral tree located at the path specified in the root argument.

§Examples
use intel_crashlog::prelude::*;
use std::path::Path;

let collateral_manager = CollateralManager::file_system_tree(Path::new("collateral"));
assert!(collateral_manager.is_ok());
Source§

impl<T: CollateralTree> CollateralManager<T>

Source

pub fn new(tree: T) -> Result<Self, Error>

Creates a collateral manager for a given collateral tree.

Source

pub fn get_item_with_pvss( &mut self, pvss: PVSS, path: impl Into<ItemPath>, ) -> Result<&[u8], Error>

Returns the content of an item from the collateral tree using the PVSS of the target.

use intel_crashlog::prelude::*;
use intel_crashlog::collateral::PVSS;

let mut cm = CollateralManager::embedded_tree().unwrap();
let pvss = PVSS {
    product: "XYZ".into(),
    security: "all".into(),
    ..PVSS::default()
};
assert!(cm.get_item_with_pvss(pvss, "target_info.json").is_ok());
Source

pub fn get_item_with_pvs( &mut self, pvss: PVSS, path: impl Into<ItemPath>, ) -> Result<&[u8], Error>

Similar to CollateralManager::get_item_with_pvss but ignores the security specified in the PVSS and returns the item with the highest security level.

use intel_crashlog::prelude::*;
use intel_crashlog::collateral::PVSS;

let mut cm = CollateralManager::embedded_tree().unwrap();
let pvss = PVSS {
    product: "XYZ".into(),
    ..PVSS::default()
};
assert!(cm.get_item_with_pvs(pvss, "target_info.json").is_ok());
Source

pub fn get_item_with_header( &mut self, header: &Header, path: impl Into<ItemPath>, ) -> Result<&[u8], Error>

Returns the content of an item from the collateral tree using the Crash Log header.

use intel_crashlog::prelude::*;

let mut cm = CollateralManager::embedded_tree().unwrap();
let data = vec![0x08, 0xa1, 0x07, 0x3e, 0x2, 0x0, 0x0, 0x0];
let header = Header::from_slice(&data).unwrap().unwrap();
assert!(cm.get_item_with_header(&header, "target_info.json").is_ok());

Trait Implementations§

Source§

impl<T: Default + CollateralTree> Default for CollateralManager<T>

Source§

fn default() -> CollateralManager<T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for CollateralManager<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for CollateralManager<T>
where T: RefUnwindSafe,

§

impl<T> Send for CollateralManager<T>
where T: Send,

§

impl<T> Sync for CollateralManager<T>
where T: Sync,

§

impl<T> Unpin for CollateralManager<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for CollateralManager<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for CollateralManager<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.