Skip to main content

RegisteredBuffers

Struct RegisteredBuffers 

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

Buffers enregistrés (REGISTER_BUFFERS2, 15) : l’épinglage et la traduction d’adresses sont faits une foisread_fixed/write_fixed évitent ce coût par op (cas chaud du data plane AirCom).

Possède les buffers épinglés ; les références d’usage (RegisteredBufferSlice) y sont liées par lifetime.

Implementations§

Source§

impl RegisteredBuffers

Source

pub fn register( ring: &mut IoUring, buffers: Vec<Vec<u8>>, ) -> Result<Self, Errno>

REGISTER_BUFFERS2 (15) : épingle des buffers Vec<u8> possédés.

§Errors

[Errno::EINVAL] si buffers est vide ou déborde un u32 ; erreurs de io_uring_register ([Errno::ENOMEM], [Errno::EFAULT]).

Source

pub fn register_mmap( ring: &mut IoUring, regions: Vec<MmapRegion>, ) -> Result<Self, Errno>

REGISTER_BUFFERS2 (15) adossé à des MmapRegion possédées (data plane : memfd partagé). Réutilise le handle de vivacité de family-mem.

§Errors

Voir RegisteredBuffers::register.

Source

pub fn update( &mut self, ring: &mut IoUring, index: u32, buffer: Vec<u8>, ) -> Result<(), Errno>

REGISTER_BUFFERS_UPDATE (16) : remplace le buffer d’indice index.

Consomme le buffer précédent (remplacement explicite). Réservé au backing Vec<u8> (les variantes mmap/clonées rendent [Errno::EINVAL]).

§Errors

[Errno::EINVAL] si index est hors borne, ou si le backing n’est pas Vec<u8> ; erreurs de io_uring_register.

Source

pub fn clone_from(ring: &mut IoUring, src: &IoUring) -> Result<Self, Errno>

REGISTER_CLONE_BUFFERS (30) : clone les buffers enregistrés du ring src (partage thread-per-core sans réépinglage).

La mémoire reste possédée par src : la table rendue ne possède rien et n’est valide que tant que src garde ses buffers enregistrés et vivants (consommation par contrat). Les RegisteredBufferSlice à utiliser proviennent de la table de src (mêmes adresses, même process).

§Errors

Erreurs de io_uring_register ([Errno::EINVAL], [Errno::EBUSY] si la table de destination est déjà peuplée).

Source

pub fn unregister(self, ring: &mut IoUring) -> Result<Vec<Vec<u8>>, Errno>

UNREGISTER_BUFFERS (1) : désenregistre et rend les buffers Vec<u8> possédés (restitution intégrale, ADR-032).

Pour un backing mmap, les régions sont consommées (munmap au dernier drop — la signature Vec<Vec<u8>> ne peut les porter ; clonez la MmapRegion avant si besoin). Pour un clone, rien à rendre.

Sûreté par construction : un RegisteredBufferSlice ne peut pas survivre à ce désenregistrement — le code suivant ne compile pas :

let buffers = RegisteredBuffers::register(ring, vec![vec![0u8; 16]]).unwrap();
let slice = buffers.slice(0, 0..8).unwrap();  // emprunte `buffers`
let _ = buffers.unregister(ring).unwrap();     // déplace `buffers`…
let _ = slice.len();                           // …emprunt encore vivant ⇒ ERREUR
§Errors

Erreurs de io_uring_register. En cas d’erreur, les buffers possédés sont libérés (la table est consommée).

Source

pub fn slice( &self, index: u32, range: Range<usize>, ) -> Option<RegisteredBufferSlice<'_>>

Tranche [range) du buffer enregistré d’indice index, pour read_fixed/write_fixed. None si l’indice/range est hors borne, ou si le backing est cloné (géométrie inconnue côté destination).

Trait Implementations§

Source§

impl Debug for RegisteredBuffers

Source§

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

Formats the value using the given formatter. Read more

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.