PspComboDirectory

Struct PspComboDirectory 

Source
pub struct PspComboDirectory<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> PspComboDirectory<'a>

Source

pub fn new(data: &'a [u8]) -> Result<Self, String>

Source

pub fn header(&self) -> &'a ComboDirectoryHeader

Source

pub fn entries(&self) -> &'a [ComboDirectoryEntry]

Examples found in repository?
examples/amd.rs (line 51)
10fn print_directory(data: &[u8], address: u64, indent: usize) {
11    //TODO: optimize
12    let mut padding = String::with_capacity(indent);
13    for i in 0..indent {
14        padding.push(' ');
15    }
16    let offset = (address & 0xFFFFFF) as usize;
17    match Directory::new(&data[offset..]) {
18        Ok(Directory::Bios(directory)) => {
19            println!("{}* {:#X}: BIOS Directory", padding, address);
20            for entry in directory.entries() {
21                println!("{}  * Type {:02X} Region {:02X} Flags {:02X} SubProg {:02X} Size {:08X} Source {:08X} Dest {:016X}: {}", padding, entry.kind, entry.region_kind, entry.flags, entry.sub_program, entry.size, entry.source, entry.destination, entry.description());
22                if entry.kind == 0x70 {
23                    print_directory(data, entry.source, indent + 4);
24                }
25            }
26        },
27        Ok(Directory::BiosCombo(combo)) => {
28            println!("{}* {:#X}: BIOS Combo Directory", padding, address);
29            for entry in combo.entries() {
30                println!("{}  * {:X?}", padding, entry);
31                print_directory(data, entry.directory, indent + 4);
32            }
33        },
34        Ok(Directory::BiosLevel2(directory)) => {
35            println!("{}* {:#X}: BIOS Level 2 Directory", padding, address);
36            for entry in directory.entries() {
37                println!("{}  * Type {:02X} Region {:02X} Flags {:02X} SubProg {:02X} Size {:08X} Source {:08X} Dest {:016X}: {}", padding, entry.kind, entry.region_kind, entry.flags, entry.sub_program, entry.size, entry.source, entry.destination, entry.description());
38            }
39        },
40        Ok(Directory::Psp(directory)) => {
41            println!("{}* {:#X}: PSP Directory", padding, address);
42            for entry in directory.entries() {
43                println!("{}  * Type {:02X} SubProg {:02X} Size {:08X} Value {:08X}: {}", padding, entry.kind, entry.sub_program, entry.size, entry.value, entry.description());
44                if entry.kind == 0x40 {
45                    print_directory(data, entry.value, indent + 4);
46                }
47            }
48        },
49        Ok(Directory::PspCombo(combo)) => {
50            println!("{}* {:#X}: PSP Combo Directory", padding, address);
51            for entry in combo.entries() {
52                println!("{}  * {:X?}", padding, entry);
53                print_directory(data, entry.directory, indent + 4);
54            }
55        },
56        Ok(Directory::PspLevel2(directory)) => {
57            println!("{}* {:#X}: PSP Level 2 Directory", padding, address);
58            for entry in directory.entries() {
59                println!("{}  * Type {:02X} SubProg {:02X} Size {:08X} Value {:08X}: {}", padding, entry.kind, entry.sub_program, entry.size, entry.value, entry.description());
60            }
61        },
62        Err(err) => {
63            println!("{}* {:#X}: failed to load directory: {}", padding, address, err);
64        }
65    }
66}

Auto Trait Implementations§

§

impl<'a> Freeze for PspComboDirectory<'a>

§

impl<'a> RefUnwindSafe for PspComboDirectory<'a>

§

impl<'a> Send for PspComboDirectory<'a>

§

impl<'a> Sync for PspComboDirectory<'a>

§

impl<'a> Unpin for PspComboDirectory<'a>

§

impl<'a> UnwindSafe for PspComboDirectory<'a>

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.