/rust/registry/src/index.crates.io-1949cf8c6b5b557f/scroll-0.10.2/src/pread.rs
Line | Count | Source |
1 | | use core::result; |
2 | | use core::ops::{Index, RangeFrom}; |
3 | | |
4 | | use crate::ctx::{TryFromCtx, MeasureWith}; |
5 | | use crate::error; |
6 | | |
7 | | /// A very generic, contextual pread interface in Rust. |
8 | | /// |
9 | | /// Like [Pwrite](trait.Pwrite.html) — but for reading! |
10 | | /// |
11 | | /// Implementing `Pread` on a data store allows you to then read almost arbitrarily complex types |
12 | | /// efficiently. |
13 | | /// |
14 | | /// To this end the Pread trait works in conjuction with the [TryFromCtx](ctx/trait.TryFromCtx.html); |
15 | | /// The `TryFromCtx` trait implemented on a type defines how to convert data to an object of that |
16 | | /// type, the Pread trait implemented on a data store defines how to extract said data from that |
17 | | /// store. |
18 | | /// |
19 | | /// It should be noted though that in this context, data does not necessarily mean `&[u8]` — |
20 | | /// `Pread` and `TryFromCtx` are generic over what 'data' means and could be implemented instead |
21 | | /// over chunks of memory or any other indexable type — but scroll does come with a set of powerful |
22 | | /// blanket implementations for data being a continous block of byte-addressable memory. |
23 | | /// |
24 | | /// Pread provides two main groups of functions: pread and gread. |
25 | | /// |
26 | | /// `pread` is the basic function that simply extracts a given type from a given data store - either |
27 | | /// using a provided Context in the case of [pread_with](trait.Pread.html#method.pread_with) or |
28 | | /// with the default context for the given type in the case of [pread](trait.Pread.html#method.pread) |
29 | | /// |
30 | | /// `gread` does in addition to that update the offset it's currently at, allowing for a cursored |
31 | | /// read — `gread_inout` expands on that and reads a number of continous types from the data store. |
32 | | /// gread again comes with `_with` variants to allow using a specific context. |
33 | | /// |
34 | | /// Since pread and friends are very generic functions their types are rather complex, but very |
35 | | /// much understandable; `TryFromCtx` is generic over `Ctx` ([described |
36 | | /// here](ctx/index.html#context)), `Output` and `Error`. The Error type is hopefully |
37 | | /// self-explanatory, however the `Output` type is rather important; it defines what Pread extracts |
38 | | /// from the data store and has to match up with what `TryFromCtx` expects as input to convert into |
39 | | /// the resulting type. scroll defaults to `&[u8]` here. |
40 | | /// |
41 | | /// Unless you need to implement your own data store — that is either can't convert to `&[u8]` or |
42 | | /// have a data that is not `&[u8]` — you will probably want to implement |
43 | | /// [TryFromCtx](ctx/trait.TryFromCtx.html) on your Rust types to be extracted. |
44 | | /// |
45 | | pub trait Pread<Ctx, E> : Index<usize> + Index<RangeFrom<usize>> + MeasureWith<Ctx> |
46 | | where |
47 | | Ctx: Copy, |
48 | | E: From<error::Error>, |
49 | | { |
50 | | #[inline] |
51 | | /// Reads a value from `self` at `offset` with a default `Ctx`. For the primitive numeric values, this will read at the machine's endianness. |
52 | | /// # Example |
53 | | /// ```rust |
54 | | /// use scroll::Pread; |
55 | | /// let bytes = [0x7fu8; 0x01]; |
56 | | /// let byte = bytes.pread::<u8>(0).unwrap(); |
57 | 67.6M | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { |
58 | 67.6M | self.pread_with(offset, Ctx::default()) |
59 | 67.6M | } <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim::secure_boot::PayloadSignHeader> Line | Count | Source | 57 | 1.79k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 1.79k | self.pread_with(offset, Ctx::default()) | 59 | 1.79k | } |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::metadata::TdxMetadataSection> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::metadata::TdxMetadataDescriptor> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader> Line | Count | Source | 57 | 16.5k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 16.5k | self.pread_with(offset, Ctx::default()) | 59 | 16.5k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader2> Line | Count | Source | 57 | 9.04k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 9.04k | self.pread_with(offset, Ctx::default()) | 59 | 9.04k | } |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader2> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::fv::FirmwareVolumeHeader> Line | Count | Source | 57 | 1.79k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 1.79k | self.pread_with(offset, Ctx::default()) | 59 | 1.79k | } |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::GuidExtension> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::FirmwareVolume> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::HandoffInfoTable> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::MemoryAllocation> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::ResourceDescription> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::Cpu> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::Header> Unexecuted instantiation: <_ as scroll::pread::Pread<_, _>>::pread::<_> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::metadata::TdxMetadataSection> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::metadata::TdxMetadataDescriptor> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader> Line | Count | Source | 57 | 27.6k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 27.6k | self.pread_with(offset, Ctx::default()) | 59 | 27.6k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader2> Line | Count | Source | 57 | 19.6k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 19.6k | self.pread_with(offset, Ctx::default()) | 59 | 19.6k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader> Line | Count | Source | 57 | 2.18k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 2.18k | self.pread_with(offset, Ctx::default()) | 59 | 2.18k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader2> Line | Count | Source | 57 | 1.00k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 1.00k | self.pread_with(offset, Ctx::default()) | 59 | 1.00k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::fv::FirmwareVolumeHeader> Line | Count | Source | 57 | 2.70k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 2.70k | self.pread_with(offset, Ctx::default()) | 59 | 2.70k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::GuidExtension> Line | Count | Source | 57 | 293k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 293k | self.pread_with(offset, Ctx::default()) | 59 | 293k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::FirmwareVolume> Line | Count | Source | 57 | 20.1k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 20.1k | self.pread_with(offset, Ctx::default()) | 59 | 20.1k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::HandoffInfoTable> Line | Count | Source | 57 | 12.0k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 12.0k | self.pread_with(offset, Ctx::default()) | 59 | 12.0k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::MemoryAllocation> Line | Count | Source | 57 | 15.1k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 15.1k | self.pread_with(offset, Ctx::default()) | 59 | 15.1k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::ResourceDescription> Line | Count | Source | 57 | 19.2k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 19.2k | self.pread_with(offset, Ctx::default()) | 59 | 19.2k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::Cpu> Line | Count | Source | 57 | 1.71k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 1.71k | self.pread_with(offset, Ctx::default()) | 59 | 1.71k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_shim_interface::td_uefi_pi::pi::hob::Header> Line | Count | Source | 57 | 1.35M | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 1.35M | self.pread_with(offset, Ctx::default()) | 59 | 1.35M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_loader::pe::Section> Line | Count | Source | 57 | 139k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 139k | self.pread_with(offset, Ctx::default()) | 59 | 139k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_loader::elf64::ELFHeader64> Line | Count | Source | 57 | 12.2k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 12.2k | self.pread_with(offset, Ctx::default()) | 59 | 12.2k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_loader::elf64::ProgramHeader> Line | Count | Source | 57 | 4.27M | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 4.27M | self.pread_with(offset, Ctx::default()) | 59 | 4.27M | } |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_loader::elf64::SectionHeader> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_loader::elf64::Dyn> Line | Count | Source | 57 | 54.4M | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 54.4M | self.pread_with(offset, Ctx::default()) | 59 | 54.4M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<td_loader::elf64::Rela> Line | Count | Source | 57 | 4.39M | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 4.39M | self.pread_with(offset, Ctx::default()) | 59 | 4.39M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<u32> Line | Count | Source | 57 | 14.3k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 14.3k | self.pread_with(offset, Ctx::default()) | 59 | 14.3k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<u16> Line | Count | Source | 57 | 2.49M | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 2.49M | self.pread_with(offset, Ctx::default()) | 59 | 2.49M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread::<u64> Line | Count | Source | 57 | 39.2k | fn pread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a, Ctx: Default { | 58 | 39.2k | self.pread_with(offset, Ctx::default()) | 59 | 39.2k | } |
|
60 | | #[inline] |
61 | | /// Reads a value from `self` at `offset` with the given `ctx` |
62 | | /// # Example |
63 | | /// ```rust |
64 | | /// use scroll::Pread; |
65 | | /// let bytes: [u8; 2] = [0xde, 0xad]; |
66 | | /// let dead: u16 = bytes.pread_with(0, scroll::BE).unwrap(); |
67 | | /// assert_eq!(dead, 0xdeadu16); |
68 | 67.6M | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { |
69 | 67.6M | let len = self.measure_with(&ctx); |
70 | 67.6M | if offset >= len { |
71 | 218 | return Err(error::Error::BadOffset(offset).into()) |
72 | 67.6M | } |
73 | 67.6M | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim::secure_boot::PayloadSignHeader>::{closure#0}Line | Count | Source | 73 | 1.72k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::metadata::TdxMetadataSection>::{closure#0}Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::metadata::TdxMetadataDescriptor>::{closure#0}<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader>::{closure#0}Line | Count | Source | 73 | 16.3k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader2>::{closure#0}Line | Count | Source | 73 | 9.03k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader>::{closure#0}Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader2>::{closure#0}<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FirmwareVolumeHeader>::{closure#0}Line | Count | Source | 73 | 1.70k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::GuidExtension>::{closure#0}Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::FirmwareVolume>::{closure#0}Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::HandoffInfoTable>::{closure#0}Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::MemoryAllocation>::{closure#0}Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::ResourceDescription>::{closure#0}Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::Cpu>::{closure#0}Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::Header>::{closure#0}Unexecuted instantiation: <_ as scroll::pread::Pread<_, _>>::pread_with::<_>::{closure#0}Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::metadata::TdxMetadataSection>::{closure#0}Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::metadata::TdxMetadataDescriptor>::{closure#0}<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader>::{closure#0}Line | Count | Source | 73 | 27.3k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader2>::{closure#0}Line | Count | Source | 73 | 19.6k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader>::{closure#0}Line | Count | Source | 73 | 2.16k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader2>::{closure#0}Line | Count | Source | 73 | 984 | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FirmwareVolumeHeader>::{closure#0}Line | Count | Source | 73 | 2.54k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::GuidExtension>::{closure#0}Line | Count | Source | 73 | 292k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::FirmwareVolume>::{closure#0}Line | Count | Source | 73 | 20.1k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::HandoffInfoTable>::{closure#0}Line | Count | Source | 73 | 12.0k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::MemoryAllocation>::{closure#0}Line | Count | Source | 73 | 15.1k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::ResourceDescription>::{closure#0}Line | Count | Source | 73 | 19.2k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::Cpu>::{closure#0}Line | Count | Source | 73 | 1.71k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::Header>::{closure#0}Line | Count | Source | 73 | 1.35M | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::pe::Section>::{closure#0}Line | Count | Source | 73 | 139k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::elf64::ELFHeader64>::{closure#0}Line | Count | Source | 73 | 12.0k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::elf64::ProgramHeader>::{closure#0}Line | Count | Source | 73 | 4.27M | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::elf64::SectionHeader>::{closure#0}<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::elf64::Dyn>::{closure#0}Line | Count | Source | 73 | 54.4M | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::elf64::Rela>::{closure#0}Line | Count | Source | 73 | 4.39M | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<u32>::{closure#0}Line | Count | Source | 73 | 14.3k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<u16>::{closure#0}Line | Count | Source | 73 | 2.49M | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<u64>::{closure#0}Line | Count | Source | 73 | 39.0k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) |
|
74 | 67.6M | } <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim::secure_boot::PayloadSignHeader> Line | Count | Source | 68 | 1.79k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 1.79k | let len = self.measure_with(&ctx); | 70 | 1.79k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 1.79k | } | 73 | 1.79k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 1.79k | } |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::metadata::TdxMetadataSection> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::metadata::TdxMetadataDescriptor> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader> Line | Count | Source | 68 | 16.5k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 16.5k | let len = self.measure_with(&ctx); | 70 | 16.5k | if offset >= len { | 71 | 18 | return Err(error::Error::BadOffset(offset).into()) | 72 | 16.4k | } | 73 | 16.4k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 16.5k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader2> Line | Count | Source | 68 | 9.04k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 9.04k | let len = self.measure_with(&ctx); | 70 | 9.04k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 9.04k | } | 73 | 9.04k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 9.04k | } |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader2> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FirmwareVolumeHeader> Line | Count | Source | 68 | 1.79k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 1.79k | let len = self.measure_with(&ctx); | 70 | 1.79k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 1.79k | } | 73 | 1.79k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 1.79k | } |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::GuidExtension> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::FirmwareVolume> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::HandoffInfoTable> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::MemoryAllocation> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::ResourceDescription> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::Cpu> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::Header> Unexecuted instantiation: <_ as scroll::pread::Pread<_, _>>::pread_with::<_> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::metadata::TdxMetadataSection> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::metadata::TdxMetadataDescriptor> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader> Line | Count | Source | 68 | 27.6k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 27.6k | let len = self.measure_with(&ctx); | 70 | 27.6k | if offset >= len { | 71 | 20 | return Err(error::Error::BadOffset(offset).into()) | 72 | 27.5k | } | 73 | 27.5k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 27.6k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FfsFileHeader2> Line | Count | Source | 68 | 19.6k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 19.6k | let len = self.measure_with(&ctx); | 70 | 19.6k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 19.6k | } | 73 | 19.6k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 19.6k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader> Line | Count | Source | 68 | 2.18k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 2.18k | let len = self.measure_with(&ctx); | 70 | 2.18k | if offset >= len { | 71 | 9 | return Err(error::Error::BadOffset(offset).into()) | 72 | 2.17k | } | 73 | 2.17k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 2.18k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::CommonSectionHeader2> Line | Count | Source | 68 | 1.00k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 1.00k | let len = self.measure_with(&ctx); | 70 | 1.00k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 1.00k | } | 73 | 1.00k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 1.00k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::fv::FirmwareVolumeHeader> Line | Count | Source | 68 | 2.70k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 2.70k | let len = self.measure_with(&ctx); | 70 | 2.70k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 2.70k | } | 73 | 2.70k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 2.70k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::GuidExtension> Line | Count | Source | 68 | 293k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 293k | let len = self.measure_with(&ctx); | 70 | 293k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 293k | } | 73 | 293k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 293k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::FirmwareVolume> Line | Count | Source | 68 | 20.1k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 20.1k | let len = self.measure_with(&ctx); | 70 | 20.1k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 20.1k | } | 73 | 20.1k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 20.1k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::HandoffInfoTable> Line | Count | Source | 68 | 12.0k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 12.0k | let len = self.measure_with(&ctx); | 70 | 12.0k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 12.0k | } | 73 | 12.0k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 12.0k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::MemoryAllocation> Line | Count | Source | 68 | 15.1k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 15.1k | let len = self.measure_with(&ctx); | 70 | 15.1k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 15.1k | } | 73 | 15.1k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 15.1k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::ResourceDescription> Line | Count | Source | 68 | 19.2k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 19.2k | let len = self.measure_with(&ctx); | 70 | 19.2k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 19.2k | } | 73 | 19.2k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 19.2k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::Cpu> Line | Count | Source | 68 | 1.71k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 1.71k | let len = self.measure_with(&ctx); | 70 | 1.71k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 1.71k | } | 73 | 1.71k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 1.71k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_shim_interface::td_uefi_pi::pi::hob::Header> Line | Count | Source | 68 | 1.35M | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 1.35M | let len = self.measure_with(&ctx); | 70 | 1.35M | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 1.35M | } | 73 | 1.35M | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 1.35M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::pe::Section> Line | Count | Source | 68 | 139k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 139k | let len = self.measure_with(&ctx); | 70 | 139k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 139k | } | 73 | 139k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 139k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::elf64::ELFHeader64> Line | Count | Source | 68 | 12.2k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 12.2k | let len = self.measure_with(&ctx); | 70 | 12.2k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 12.2k | } | 73 | 12.2k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 12.2k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::elf64::ProgramHeader> Line | Count | Source | 68 | 4.27M | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 4.27M | let len = self.measure_with(&ctx); | 70 | 4.27M | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 4.27M | } | 73 | 4.27M | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 4.27M | } |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::elf64::SectionHeader> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::elf64::Dyn> Line | Count | Source | 68 | 54.4M | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 54.4M | let len = self.measure_with(&ctx); | 70 | 54.4M | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 54.4M | } | 73 | 54.4M | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 54.4M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<td_loader::elf64::Rela> Line | Count | Source | 68 | 4.39M | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 4.39M | let len = self.measure_with(&ctx); | 70 | 4.39M | if offset >= len { | 71 | 3 | return Err(error::Error::BadOffset(offset).into()) | 72 | 4.39M | } | 73 | 4.39M | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 4.39M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<u32> Line | Count | Source | 68 | 14.3k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 14.3k | let len = self.measure_with(&ctx); | 70 | 14.3k | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 14.3k | } | 73 | 14.3k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 14.3k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<u16> Line | Count | Source | 68 | 2.49M | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 2.49M | let len = self.measure_with(&ctx); | 70 | 2.49M | if offset >= len { | 71 | 0 | return Err(error::Error::BadOffset(offset).into()) | 72 | 2.49M | } | 73 | 2.49M | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 2.49M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::pread_with::<u64> Line | Count | Source | 68 | 39.2k | fn pread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: usize, ctx: Ctx) -> result::Result<N, E> where <Self as Index<RangeFrom<usize>>>::Output: 'a { | 69 | 39.2k | let len = self.measure_with(&ctx); | 70 | 39.2k | if offset >= len { | 71 | 168 | return Err(error::Error::BadOffset(offset).into()) | 72 | 39.1k | } | 73 | 39.1k | N::try_from_ctx(&self[offset..], ctx).and_then(|(n, _)| Ok(n)) | 74 | 39.2k | } |
|
75 | | #[inline] |
76 | | /// Reads a value from `self` at `offset` with a default `Ctx`. For the primitive numeric values, this will read at the machine's endianness. Updates the offset |
77 | | /// # Example |
78 | | /// ```rust |
79 | | /// use scroll::Pread; |
80 | | /// let offset = &mut 0; |
81 | | /// let bytes = [0x7fu8; 0x01]; |
82 | | /// let byte = bytes.gread::<u8>(offset).unwrap(); |
83 | | /// assert_eq!(*offset, 1); |
84 | 0 | fn gread<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>>(&'a self, offset: &mut usize) -> result::Result<N, E> where Ctx: Default, <Self as Index<RangeFrom<usize>>>::Output: 'a { |
85 | 0 | let ctx = Ctx::default(); |
86 | 0 | self.gread_with(offset, ctx) |
87 | 0 | } Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread::<td_shim::secure_boot::CfvPubKeyFileHeader> Unexecuted instantiation: <_ as scroll::pread::Pread<_, _>>::gread::<_> |
88 | | /// Reads a value from `self` at `offset` with the given `ctx`, and updates the offset. |
89 | | /// # Example |
90 | | /// ```rust |
91 | | /// use scroll::Pread; |
92 | | /// let offset = &mut 0; |
93 | | /// let bytes: [u8; 2] = [0xde, 0xad]; |
94 | | /// let dead: u16 = bytes.gread_with(offset, scroll::BE).unwrap(); |
95 | | /// assert_eq!(dead, 0xdeadu16); |
96 | | /// assert_eq!(*offset, 2); |
97 | | #[inline] |
98 | 172M | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> |
99 | 172M | (&'a self, offset: &mut usize, ctx: Ctx) -> |
100 | 172M | result::Result<N, E> |
101 | 172M | where <Self as Index<RangeFrom<usize>>>::Output: 'a |
102 | | { |
103 | 172M | let o = *offset; |
104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { |
105 | | // *offset += size; |
106 | | // Ok(n) |
107 | | // }) |
108 | 172M | let len = self.measure_with(&ctx); |
109 | 172M | if o >= len { |
110 | 2.64k | return Err(error::Error::BadOffset(o).into()) |
111 | 172M | } |
112 | 172M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { |
113 | 172M | *offset += size; |
114 | 172M | Ok(n) |
115 | 172M | }) Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim::secure_boot::CfvPubKeyFileHeader>::{closure#0}<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::fv::Checksum>::{closure#0}Line | Count | Source | 112 | 25.4k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 25.4k | *offset += size; | 114 | 25.4k | Ok(n) | 115 | 25.4k | }) |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::hob::MemoryAllocationHeader>::{closure#0}Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::hob::Header>::{closure#0}<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u8>::{closure#0}Line | Count | Source | 112 | 698k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 698k | *offset += size; | 114 | 698k | Ok(n) | 115 | 698k | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u32>::{closure#0}Line | Count | Source | 112 | 19.3k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 19.3k | *offset += size; | 114 | 19.3k | Ok(n) | 115 | 19.3k | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u16>::{closure#0}Line | Count | Source | 112 | 5.13k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 5.13k | *offset += size; | 114 | 5.13k | Ok(n) | 115 | 5.13k | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u64>::{closure#0}Line | Count | Source | 112 | 5.17k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 5.17k | *offset += size; | 114 | 5.17k | Ok(n) | 115 | 5.17k | }) |
Unexecuted instantiation: <_ as scroll::pread::Pread<_, _>>::gread_with::<_>::{closure#0}<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::fv::Checksum>::{closure#0}Line | Count | Source | 112 | 47.0k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 47.0k | *offset += size; | 114 | 47.0k | Ok(n) | 115 | 47.0k | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::hob::MemoryAllocationHeader>::{closure#0}Line | Count | Source | 112 | 15.1k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 15.1k | *offset += size; | 114 | 15.1k | Ok(n) | 115 | 15.1k | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::hob::Header>::{closure#0}Line | Count | Source | 112 | 361k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 361k | *offset += size; | 114 | 361k | Ok(n) | 115 | 361k | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u8>::{closure#0}Line | Count | Source | 112 | 6.54M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 6.54M | *offset += size; | 114 | 6.54M | Ok(n) | 115 | 6.54M | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u32>::{closure#0}Line | Count | Source | 112 | 1.81M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 1.81M | *offset += size; | 114 | 1.81M | Ok(n) | 115 | 1.81M | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u16>::{closure#0}Line | Count | Source | 112 | 3.43M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 3.43M | *offset += size; | 114 | 3.43M | Ok(n) | 115 | 3.43M | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u64>::{closure#0}Line | Count | Source | 112 | 171k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 171k | *offset += size; | 114 | 171k | Ok(n) | 115 | 171k | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u8>::{closure#0}Line | Count | Source | 112 | 1.31M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 1.31M | *offset += size; | 114 | 1.31M | Ok(n) | 115 | 1.31M | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u32>::{closure#0}Line | Count | Source | 112 | 9.55M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 9.55M | *offset += size; | 114 | 9.55M | Ok(n) | 115 | 9.55M | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u16>::{closure#0}Line | Count | Source | 112 | 376k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 376k | *offset += size; | 114 | 376k | Ok(n) | 115 | 376k | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<i64>::{closure#0}Line | Count | Source | 112 | 4.39M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 4.39M | *offset += size; | 114 | 4.39M | Ok(n) | 115 | 4.39M | }) |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u64>::{closure#0}Line | Count | Source | 112 | 143M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | 143M | *offset += size; | 114 | 143M | Ok(n) | 115 | 143M | }) |
|
116 | 172M | } Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim::secure_boot::CfvPubKeyFileHeader> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::fv::Checksum> Line | Count | Source | 98 | 25.4k | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 25.4k | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 25.4k | result::Result<N, E> | 101 | 25.4k | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 25.4k | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 25.4k | let len = self.measure_with(&ctx); | 109 | 25.4k | if o >= len { | 110 | 11 | return Err(error::Error::BadOffset(o).into()) | 111 | 25.4k | } | 112 | 25.4k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 25.4k | } |
Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::hob::MemoryAllocationHeader> Unexecuted instantiation: <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::hob::Header> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u8> Line | Count | Source | 98 | 698k | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 698k | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 698k | result::Result<N, E> | 101 | 698k | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 698k | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 698k | let len = self.measure_with(&ctx); | 109 | 698k | if o >= len { | 110 | 227 | return Err(error::Error::BadOffset(o).into()) | 111 | 698k | } | 112 | 698k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 698k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u32> Line | Count | Source | 98 | 19.4k | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 19.4k | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 19.4k | result::Result<N, E> | 101 | 19.4k | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 19.4k | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 19.4k | let len = self.measure_with(&ctx); | 109 | 19.4k | if o >= len { | 110 | 10 | return Err(error::Error::BadOffset(o).into()) | 111 | 19.4k | } | 112 | 19.4k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 19.4k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u16> Line | Count | Source | 98 | 5.13k | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 5.13k | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 5.13k | result::Result<N, E> | 101 | 5.13k | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 5.13k | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 5.13k | let len = self.measure_with(&ctx); | 109 | 5.13k | if o >= len { | 110 | 3 | return Err(error::Error::BadOffset(o).into()) | 111 | 5.13k | } | 112 | 5.13k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 5.13k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u64> Line | Count | Source | 98 | 5.20k | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 5.20k | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 5.20k | result::Result<N, E> | 101 | 5.20k | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 5.20k | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 5.20k | let len = self.measure_with(&ctx); | 109 | 5.20k | if o >= len { | 110 | 3 | return Err(error::Error::BadOffset(o).into()) | 111 | 5.19k | } | 112 | 5.19k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 5.20k | } |
Unexecuted instantiation: <_ as scroll::pread::Pread<_, _>>::gread_with::<_> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::fv::Checksum> Line | Count | Source | 98 | 47.0k | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 47.0k | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 47.0k | result::Result<N, E> | 101 | 47.0k | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 47.0k | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 47.0k | let len = self.measure_with(&ctx); | 109 | 47.0k | if o >= len { | 110 | 16 | return Err(error::Error::BadOffset(o).into()) | 111 | 47.0k | } | 112 | 47.0k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 47.0k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::hob::MemoryAllocationHeader> Line | Count | Source | 98 | 15.1k | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 15.1k | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 15.1k | result::Result<N, E> | 101 | 15.1k | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 15.1k | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 15.1k | let len = self.measure_with(&ctx); | 109 | 15.1k | if o >= len { | 110 | 0 | return Err(error::Error::BadOffset(o).into()) | 111 | 15.1k | } | 112 | 15.1k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 15.1k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<td_shim_interface::td_uefi_pi::pi::hob::Header> Line | Count | Source | 98 | 361k | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 361k | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 361k | result::Result<N, E> | 101 | 361k | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 361k | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 361k | let len = self.measure_with(&ctx); | 109 | 361k | if o >= len { | 110 | 0 | return Err(error::Error::BadOffset(o).into()) | 111 | 361k | } | 112 | 361k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 361k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u8> Line | Count | Source | 98 | 6.54M | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 6.54M | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 6.54M | result::Result<N, E> | 101 | 6.54M | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 6.54M | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 6.54M | let len = self.measure_with(&ctx); | 109 | 6.54M | if o >= len { | 110 | 623 | return Err(error::Error::BadOffset(o).into()) | 111 | 6.54M | } | 112 | 6.54M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 6.54M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u32> Line | Count | Source | 98 | 1.81M | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 1.81M | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 1.81M | result::Result<N, E> | 101 | 1.81M | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 1.81M | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 1.81M | let len = self.measure_with(&ctx); | 109 | 1.81M | if o >= len { | 110 | 18 | return Err(error::Error::BadOffset(o).into()) | 111 | 1.81M | } | 112 | 1.81M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 1.81M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u16> Line | Count | Source | 98 | 3.43M | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 3.43M | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 3.43M | result::Result<N, E> | 101 | 3.43M | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 3.43M | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 3.43M | let len = self.measure_with(&ctx); | 109 | 3.43M | if o >= len { | 110 | 10 | return Err(error::Error::BadOffset(o).into()) | 111 | 3.43M | } | 112 | 3.43M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 3.43M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u64> Line | Count | Source | 98 | 171k | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 171k | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 171k | result::Result<N, E> | 101 | 171k | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 171k | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 171k | let len = self.measure_with(&ctx); | 109 | 171k | if o >= len { | 110 | 6 | return Err(error::Error::BadOffset(o).into()) | 111 | 171k | } | 112 | 171k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 171k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u8> Line | Count | Source | 98 | 1.31M | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 1.31M | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 1.31M | result::Result<N, E> | 101 | 1.31M | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 1.31M | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 1.31M | let len = self.measure_with(&ctx); | 109 | 1.31M | if o >= len { | 110 | 44 | return Err(error::Error::BadOffset(o).into()) | 111 | 1.31M | } | 112 | 1.31M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 1.31M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u32> Line | Count | Source | 98 | 9.55M | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 9.55M | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 9.55M | result::Result<N, E> | 101 | 9.55M | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 9.55M | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 9.55M | let len = self.measure_with(&ctx); | 109 | 9.55M | if o >= len { | 110 | 108 | return Err(error::Error::BadOffset(o).into()) | 111 | 9.55M | } | 112 | 9.55M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 9.55M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u16> Line | Count | Source | 98 | 376k | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 376k | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 376k | result::Result<N, E> | 101 | 376k | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 376k | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 376k | let len = self.measure_with(&ctx); | 109 | 376k | if o >= len { | 110 | 16 | return Err(error::Error::BadOffset(o).into()) | 111 | 376k | } | 112 | 376k | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 376k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<i64> Line | Count | Source | 98 | 4.39M | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 4.39M | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 4.39M | result::Result<N, E> | 101 | 4.39M | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 4.39M | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 4.39M | let len = self.measure_with(&ctx); | 109 | 4.39M | if o >= len { | 110 | 19 | return Err(error::Error::BadOffset(o).into()) | 111 | 4.39M | } | 112 | 4.39M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 4.39M | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_with::<u64> Line | Count | Source | 98 | 143M | fn gread_with<'a, N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>> | 99 | 143M | (&'a self, offset: &mut usize, ctx: Ctx) -> | 100 | 143M | result::Result<N, E> | 101 | 143M | where <Self as Index<RangeFrom<usize>>>::Output: 'a | 102 | | { | 103 | 143M | let o = *offset; | 104 | | // self.pread_with(o, ctx).and_then(|(n, size)| { | 105 | | // *offset += size; | 106 | | // Ok(n) | 107 | | // }) | 108 | 143M | let len = self.measure_with(&ctx); | 109 | 143M | if o >= len { | 110 | 1.52k | return Err(error::Error::BadOffset(o).into()) | 111 | 143M | } | 112 | 143M | N::try_from_ctx(&self[o..], ctx).and_then(|(n, size)| { | 113 | | *offset += size; | 114 | | Ok(n) | 115 | | }) | 116 | 143M | } |
|
117 | | |
118 | | /// Trys to write `inout.len()` `N`s into `inout` from `Self` starting at `offset`, using the default context for `N`, and updates the offset. |
119 | | /// # Example |
120 | | /// ```rust |
121 | | /// use scroll::Pread; |
122 | | /// let mut bytes: Vec<u8> = vec![0, 0]; |
123 | | /// let offset = &mut 0; |
124 | | /// let bytes_from: [u8; 2] = [0x48, 0x49]; |
125 | | /// bytes_from.gread_inout(offset, &mut bytes).unwrap(); |
126 | | /// assert_eq!(&bytes, &bytes_from); |
127 | | /// assert_eq!(*offset, 2); |
128 | | #[inline] |
129 | 0 | fn gread_inout<'a, N>(&'a self, offset: &mut usize, inout: &mut [N]) -> result::Result<(), E> |
130 | 0 | where |
131 | 0 | N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>, |
132 | 0 | Ctx: Default, |
133 | 0 | <Self as Index<RangeFrom<usize>>>::Output: 'a |
134 | | { |
135 | 0 | for i in inout.iter_mut() { |
136 | 0 | *i = self.gread(offset)?; |
137 | | } |
138 | 0 | Ok(()) |
139 | 0 | } |
140 | | |
141 | | /// Trys to write `inout.len()` `N`s into `inout` from `Self` starting at `offset`, using the context `ctx` |
142 | | /// # Example |
143 | | /// ```rust |
144 | | /// use scroll::{ctx, LE, Pread}; |
145 | | /// let mut bytes: Vec<u8> = vec![0, 0]; |
146 | | /// let offset = &mut 0; |
147 | | /// let bytes_from: [u8; 2] = [0x48, 0x49]; |
148 | | /// bytes_from.gread_inout_with(offset, &mut bytes, LE).unwrap(); |
149 | | /// assert_eq!(&bytes, &bytes_from); |
150 | | /// assert_eq!(*offset, 2); |
151 | | #[inline] |
152 | 655k | fn gread_inout_with<'a, N>(&'a self, offset: &mut usize, inout: &mut [N], ctx: Ctx) -> result::Result<(), E> |
153 | 655k | where |
154 | 655k | N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>, |
155 | 655k | <Self as Index<RangeFrom<usize>>>::Output: 'a |
156 | | { |
157 | 8.17M | for i in inout.iter_mut() { |
158 | 8.17M | *i = self.gread_with(offset, ctx)?; |
159 | | } |
160 | 654k | Ok(()) |
161 | 655k | } <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_inout_with::<u8> Line | Count | Source | 152 | 56.2k | fn gread_inout_with<'a, N>(&'a self, offset: &mut usize, inout: &mut [N], ctx: Ctx) -> result::Result<(), E> | 153 | 56.2k | where | 154 | 56.2k | N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>, | 155 | 56.2k | <Self as Index<RangeFrom<usize>>>::Output: 'a | 156 | | { | 157 | 568k | for i in inout.iter_mut() { | 158 | 568k | *i = self.gread_with(offset, ctx)?; | 159 | | } | 160 | 56.0k | Ok(()) | 161 | 56.2k | } |
Unexecuted instantiation: <_ as scroll::pread::Pread<_, _>>::gread_inout_with::<_> <[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_inout_with::<u8> Line | Count | Source | 152 | 446k | fn gread_inout_with<'a, N>(&'a self, offset: &mut usize, inout: &mut [N], ctx: Ctx) -> result::Result<(), E> | 153 | 446k | where | 154 | 446k | N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>, | 155 | 446k | <Self as Index<RangeFrom<usize>>>::Output: 'a | 156 | | { | 157 | 6.29M | for i in inout.iter_mut() { | 158 | 6.29M | *i = self.gread_with(offset, ctx)?; | 159 | | } | 160 | 446k | Ok(()) | 161 | 446k | } |
<[u8] as scroll::pread::Pread<scroll::endian::Endian, scroll::error::Error>>::gread_inout_with::<u8> Line | Count | Source | 152 | 152k | fn gread_inout_with<'a, N>(&'a self, offset: &mut usize, inout: &mut [N], ctx: Ctx) -> result::Result<(), E> | 153 | 152k | where | 154 | 152k | N: TryFromCtx<'a, Ctx, <Self as Index<RangeFrom<usize>>>::Output, Error = E>, | 155 | 152k | <Self as Index<RangeFrom<usize>>>::Output: 'a | 156 | | { | 157 | 1.31M | for i in inout.iter_mut() { | 158 | 1.31M | *i = self.gread_with(offset, ctx)?; | 159 | | } | 160 | 151k | Ok(()) | 161 | 152k | } |
|
162 | | } |
163 | | |
164 | | impl<Ctx: Copy, |
165 | | E: From<error::Error>, |
166 | | R: ?Sized + Index<usize> + Index<RangeFrom<usize>> + MeasureWith<Ctx>> |
167 | | Pread<Ctx, E> for R {} |