pub struct CollateralManager<T: CollateralTree> {
pub target_info: HashMap<u32, TargetInfo>,
/* private fields */
}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>
impl CollateralManager<EmbeddedTree>
Sourcepub fn embedded_tree() -> Result<Self, Error>
Available on crate feature embedded_collateral_tree only.
pub fn embedded_tree() -> Result<Self, Error>
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>
impl CollateralManager<FileSystemTree>
Sourcepub fn file_system_tree(root: &Path) -> Result<Self, Error>
Available on crate feature fs_collateral_tree only.
pub fn file_system_tree(root: &Path) -> Result<Self, Error>
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>
impl<T: CollateralTree> CollateralManager<T>
Sourcepub fn new(tree: T) -> Result<Self, Error>
pub fn new(tree: T) -> Result<Self, Error>
Creates a collateral manager for a given collateral tree.
Sourcepub fn get_item_with_pvss(
&mut self,
pvss: PVSS,
path: impl Into<ItemPath>,
) -> Result<&[u8], Error>
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());Sourcepub fn get_item_with_pvs(
&mut self,
pvss: PVSS,
path: impl Into<ItemPath>,
) -> Result<&[u8], Error>
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());Sourcepub fn get_item_with_header(
&mut self,
header: &Header,
path: impl Into<ItemPath>,
) -> Result<&[u8], Error>
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());