pub struct View<T> { /* private fields */ }Expand description
A view into a policy object.
This struct contains the start and end offsets of the object in the policy data. To read the
object, use View::read.
Implementations§
Source§impl<T> View<T>
 
impl<T> View<T>
Sourcepub fn new(start: PolicyOffset, end: PolicyOffset) -> Self
 
pub fn new(start: PolicyOffset, end: PolicyOffset) -> Self
Creates a new view from the start and end offsets.
Source§impl<T: Sized> View<T>
 
impl<T: Sized> View<T>
Sourcepub fn at(start: PolicyOffset) -> Self
 
pub fn at(start: PolicyOffset) -> Self
Creates a new view at the given start offset.
The end offset is calculated as the start offset plus the size of the object.
Source§impl<T: FromBytes + Sized> View<T>
 
impl<T: FromBytes + Sized> View<T>
Sourcepub fn read(&self, policy_data: &PolicyData) -> T
 
pub fn read(&self, policy_data: &PolicyData) -> T
Reads the object from the policy data.
This function requires the object to have a fixed size and simply copies the object from the policy data.
For variable-sized objects, use View::parse instead.
Source§impl<T: HasMetadata> View<T>
 
impl<T: HasMetadata> View<T>
Sourcepub fn metadata(&self) -> View<T::Metadata>
 
pub fn metadata(&self) -> View<T::Metadata>
Returns a view into the metadata of the object.
Assumes the metadata is at the start of the object.
Sourcepub fn read_metadata(&self, policy_data: &PolicyData) -> T::Metadata
 
pub fn read_metadata(&self, policy_data: &PolicyData) -> T::Metadata
Reads the metadata from the policy data.
Source§impl<T: Parse> View<T>
 
impl<T: Parse> View<T>
Sourcepub fn parse(&self, policy_data: &PolicyData) -> T
 
pub fn parse(&self, policy_data: &PolicyData) -> T
Parses the object from the policy data.
This function uses the Parse trait to parse the object from the policy data.
If the object has a fixed size, prefer View::read instead.