Struct memory::BorrowedMappedPages
source · pub struct BorrowedMappedPages<T, M = Immutable, B = MappedPages>where
T: FromBytes,
M: Mutability,
B: Borrow<MappedPages>,{ /* private fields */ }Expand description
A borrowed MappedPages object that derefs to &T and optionally also &mut T.
Type parameters
T: FromBytes: the same parameter used inMappedPages::as_type()functions.M: Mutability: whether or not theMappedPagescan be mutably borrowed.- For ease of use, the default is
Immutable.
- For ease of use, the default is
B: Borrow<MappedPages>: enables the user of this type to use a borrow-able wrapper type or reference aroundMappedPages.- For ease of use, the default is just a plain
MappedPageswith no wrapper. This defaultMappedPagestype can be borrowed immutably or mutably. - Example types that satisfy the bounds for
BareArc<MappedPages,Rc<MappedPages>,&MappedPages, etc, all of which can only be borrowed immutably via thefrom()method, as these types do not permit mutable access. For mutable borrows, see thefrom_mut()method, which works with types likeMappedPagesitself or&mut MappedPages.
- For ease of use, the default is just a plain
Drop behavior
- When dropped, the borrow ends and the contained
MappedPagesis dropped and unmapped. - Also, you can manually end the borrow to reclaim the inner
BMappedPagestype via theSelf::into_inner()method.
Implementations§
source§impl<T: FromBytes, B: Borrow<MappedPages>> BorrowedMappedPages<T, Immutable, B>
impl<T: FromBytes, B: Borrow<MappedPages>> BorrowedMappedPages<T, Immutable, B>
sourcepub fn from(mp: B, byte_offset: usize) -> Result<Self, (B, &'static str)>
pub fn from(mp: B, byte_offset: usize) -> Result<Self, (B, &'static str)>
Immutably borrows the given MappedPages as an instance of type &T
located at the given byte_offset into the MappedPages.
See MappedPages::as_type() for more info.
Arguments
mp: theMappedPagesthat you wish to immutably borrow as an instance of&T.- See the type-level docs for more info and examples of how to use this argument.
byte_offset: the offset (in number of bytes) from the beginning of theMappedPagesmemory region at which the structTis located (where it should start).- This offset must be properly aligned with respect to the alignment requirements
of type
T, otherwise an error will be returned.
- This offset must be properly aligned with respect to the alignment requirements
of type
Upon failure, this returns an error tuple containing the unmodified mp argument
and a string describing the error.
source§impl<T: FromBytes, B: BorrowMut<MappedPages>> BorrowedMappedPages<T, Mutable, B>
impl<T: FromBytes, B: BorrowMut<MappedPages>> BorrowedMappedPages<T, Mutable, B>
sourcepub fn from_mut(mp: B, byte_offset: usize) -> Result<Self, (B, &'static str)>
pub fn from_mut(mp: B, byte_offset: usize) -> Result<Self, (B, &'static str)>
Mutably borrows the given MappedPages as an instance of type &mut T
located at the given byte_offset into the MappedPages.
See MappedPages::as_type_mut() for more info.
Arguments
mp: theMappedPagesthat you wish to mutably borrow as an instance of&mut T.- See the type-level docs for more info and examples of how to use this argument.
byte_offset: the offset (in number of bytes) from the beginning of theMappedPagesmemory region at which the structTis located (where it should start).- This offset must be properly aligned with respect to the alignment requirements
of type
T, otherwise an error will be returned.
- This offset must be properly aligned with respect to the alignment requirements
of type
Upon failure, returns an error containing the unmodified MappedPages
and a string describing the error.
source§impl<T: FromBytes, M: Mutability, B: Borrow<MappedPages>> BorrowedMappedPages<T, M, B>
impl<T: FromBytes, M: Mutability, B: Borrow<MappedPages>> BorrowedMappedPages<T, M, B>
sourcepub fn into_inner(self) -> B
pub fn into_inner(self) -> B
Consumes this object and returns the inner MappedPages value
(more specifically, the Borrow-able container holding the MappedPages).
Trait Implementations§
source§impl<T: FromBytes, B: BorrowMut<MappedPages>> AsMut<T> for BorrowedMappedPages<T, Mutable, B>
impl<T: FromBytes, B: BorrowMut<MappedPages>> AsMut<T> for BorrowedMappedPages<T, Mutable, B>
Only Mutable BorrowedMappedPages implement AsMut<T>.
source§impl<T: FromBytes, M: Mutability, B: Borrow<MappedPages>> AsRef<T> for BorrowedMappedPages<T, M, B>
impl<T: FromBytes, M: Mutability, B: Borrow<MappedPages>> AsRef<T> for BorrowedMappedPages<T, M, B>
Both Mutable and Immutable BorrowedMappedPages implement AsRef<T>.
source§impl<T: FromBytes, M: Mutability, B: Borrow<MappedPages>> Borrow<T> for BorrowedMappedPages<T, M, B>
impl<T: FromBytes, M: Mutability, B: Borrow<MappedPages>> Borrow<T> for BorrowedMappedPages<T, M, B>
Both Mutable and Immutable BorrowedMappedPages implement Borrow<T>.
source§impl<T: FromBytes, B: BorrowMut<MappedPages>> BorrowMut<T> for BorrowedMappedPages<T, Mutable, B>
impl<T: FromBytes, B: BorrowMut<MappedPages>> BorrowMut<T> for BorrowedMappedPages<T, Mutable, B>
Only Mutable BorrowedMappedPages implement BorrowMut<T>.
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T: FromBytes, M: Mutability, B: Borrow<MappedPages>> Deref for BorrowedMappedPages<T, M, B>
impl<T: FromBytes, M: Mutability, B: Borrow<MappedPages>> Deref for BorrowedMappedPages<T, M, B>
Both Mutable and Immutable BorrowedMappedPages can deref into &T.
source§impl<T: FromBytes, B: BorrowMut<MappedPages>> DerefMut for BorrowedMappedPages<T, Mutable, B>
impl<T: FromBytes, B: BorrowMut<MappedPages>> DerefMut for BorrowedMappedPages<T, Mutable, B>
Only Mutable BorrowedMappedPages can deref into &mut T.
source§impl<T: FromBytes + Hash, M: Mutability, B: Borrow<MappedPages>> Hash for BorrowedMappedPages<T, M, B>
impl<T: FromBytes + Hash, M: Mutability, B: Borrow<MappedPages>> Hash for BorrowedMappedPages<T, M, B>
source§impl<T: FromBytes + Ord, M: Mutability, B: Borrow<MappedPages>> Ord for BorrowedMappedPages<T, M, B>
impl<T: FromBytes + Ord, M: Mutability, B: Borrow<MappedPages>> Ord for BorrowedMappedPages<T, M, B>
source§impl<T: FromBytes + PartialEq, M: Mutability, B: Borrow<MappedPages>> PartialEq<BorrowedMappedPages<T, M, B>> for BorrowedMappedPages<T, M, B>
impl<T: FromBytes + PartialEq, M: Mutability, B: Borrow<MappedPages>> PartialEq<BorrowedMappedPages<T, M, B>> for BorrowedMappedPages<T, M, B>
source§impl<T: FromBytes + PartialOrd, M: Mutability, B: Borrow<MappedPages>> PartialOrd<BorrowedMappedPages<T, M, B>> for BorrowedMappedPages<T, M, B>
impl<T: FromBytes + PartialOrd, M: Mutability, B: Borrow<MappedPages>> PartialOrd<BorrowedMappedPages<T, M, B>> for BorrowedMappedPages<T, M, B>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more