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.
Trait Implementations§
impl<T: Copy> Copy for View<T>
Auto Trait Implementations§
impl<T> Freeze for View<T>
impl<T> RefUnwindSafe for View<T>where
T: RefUnwindSafe,
impl<T> Send for View<T>where
T: Send,
impl<T> Sync for View<T>where
T: Sync,
impl<T> Unpin for View<T>where
T: Unpin,
impl<T> UnwindSafe for View<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more