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

  1. T: FromBytes: the same parameter used in MappedPages::as_type() functions.
  2. M: Mutability: whether or not the MappedPages can be mutably borrowed.
  3. B: Borrow<MappedPages>: enables the user of this type to use a borrow-able wrapper type or reference around MappedPages.
    • For ease of use, the default is just a plain MappedPages with no wrapper. This default MappedPages type can be borrowed immutably or mutably.
    • Example types that satisfy the bounds for B are Arc<MappedPages, Rc<MappedPages>, &MappedPages, etc, all of which can only be borrowed immutably via the from() method, as these types do not permit mutable access. For mutable borrows, see the from_mut() method, which works with types like MappedPages itself or &mut MappedPages.

Drop behavior

  • When dropped, the borrow ends and the contained MappedPages is dropped and unmapped.
  • Also, you can manually end the borrow to reclaim the inner B MappedPages type via the Self::into_inner() method.

Implementations§

source§

impl<T: FromBytes, B: Borrow<MappedPages>> BorrowedMappedPages<T, Immutable, B>

source

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: the MappedPages that 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 the MappedPages memory region at which the struct T is 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.

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>

source

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: the MappedPages that 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 the MappedPages memory region at which the struct T is 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.

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>

source

pub fn into_inner(self) -> B

Consumes this object and returns the inner MappedPages value (more specifically, the Borrow-able container holding the MappedPages).

source

pub fn inner_ref(&self) -> &B

Returns a reference to 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>

Only Mutable BorrowedMappedPages implement AsMut<T>.

source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<T: FromBytes, M: Mutability, B: Borrow<MappedPages>> AsRef<T> for BorrowedMappedPages<T, M, B>

Both Mutable and Immutable BorrowedMappedPages implement AsRef<T>.

source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: FromBytes, M: Mutability, B: Borrow<MappedPages>> Borrow<T> for BorrowedMappedPages<T, M, B>

Both Mutable and Immutable BorrowedMappedPages implement Borrow<T>.

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

Mutably borrows from an owned value. Read more
source§

impl<T: FromBytes, M: Mutability, B: Borrow<MappedPages>> Deref for BorrowedMappedPages<T, M, B>

Both Mutable and Immutable BorrowedMappedPages can deref into &T.

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<T: FromBytes, B: BorrowMut<MappedPages>> DerefMut for BorrowedMappedPages<T, Mutable, B>

Only Mutable BorrowedMappedPages can deref into &mut T.

source§

fn deref_mut(&mut self) -> &mut T

Mutably dereferences the value.
source§

impl<T: FromBytes + Hash, M: Mutability, B: Borrow<MappedPages>> Hash for BorrowedMappedPages<T, M, B>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: FromBytes + Ord, M: Mutability, B: Borrow<MappedPages>> Ord for BorrowedMappedPages<T, M, B>

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl<T: FromBytes + PartialEq, M: Mutability, B: Borrow<MappedPages>> PartialEq<BorrowedMappedPages<T, M, B>> for BorrowedMappedPages<T, M, B>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: FromBytes + PartialOrd, M: Mutability, B: Borrow<MappedPages>> PartialOrd<BorrowedMappedPages<T, M, B>> for BorrowedMappedPages<T, M, B>

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T: FromBytes + Eq, M: Mutability, B: Borrow<MappedPages>> Eq for BorrowedMappedPages<T, M, B>

Auto Trait Implementations§

§

impl<T, M, B> RefUnwindSafe for BorrowedMappedPages<T, M, B>where B: RefUnwindSafe, M: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, M, B> Send for BorrowedMappedPages<T, M, B>where B: Send, M: Send, T: Send,

§

impl<T, M, B> Sync for BorrowedMappedPages<T, M, B>where B: Sync, M: Sync, T: Sync,

§

impl<T, M, B> Unpin for BorrowedMappedPages<T, M, B>where B: Unpin, M: Unpin, T: Unpin,

§

impl<T, M, B> UnwindSafe for BorrowedMappedPages<T, M, B>where B: UnwindSafe, M: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.