Skip to main content

Mapping

Struct Mapping 

Source
pub struct Mapping { /* private fields */ }
Expand description

Mapping mémoire RAII.

Crée automatiquement par mmap_anonymous, mmap_file et retourné par mremap. Appelle munmap(2) automatiquement à la destruction pour éviter tout fuite de mémoire mappée.

Contrairement à un [MappingPointer] brut, ce type garantit que munmap sera appelé exactement une fois, même en cas de panique.

Le Drop automatique ignore l’erreur de munmap (cas extrêmement rare sur Linux moderne). Pour récupérer une éventuelle erreur, utiliser munmap qui consomme le Mapping explicitement.

Implementations§

Source§

impl Mapping

Source

pub fn as_ptr(&self) -> *const u8

Retourne un pointeur constant vers le début du mapping.

Source

pub fn as_mut_ptr(&mut self) -> *mut u8

Retourne un pointeur mutable vers le début du mapping.

Source

pub fn len(&self) -> usize

Longueur du mapping en octets.

Source

pub fn is_empty(&self) -> bool

Retourne true si la longueur est zéro (mapping vide).

Source

pub fn as_slice(&self) -> &[u8]

Vue en lecture du mapping sous forme de slice d’octets.

§Safety

Le mapping doit être lisible (au moins ProtectionFlags::READ) et le contenu doit être valide pour la durée de vie de la référence retournée.

Source

pub unsafe fn as_mut_slice(&mut self) -> &mut [u8]

Vue en écriture du mapping sous forme de slice d’octets.

§Safety

Le mapping doit être accessible en écriture (au moins ProtectionFlags::WRITE). L’appelant est responsable de ne pas créer de références Rust aliasées sur la même plage mémoire.

Trait Implementations§

Source§

impl Debug for Mapping

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Mapping

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Mapping

Source§

impl Sync for Mapping

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Source§

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.