Skip to main content

ProvidedBufferRing

Struct ProvidedBufferRing 

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

Groupe de buffers fournis ring-mapped (IORING_REGISTER_PBUF_RING, 22).

Possède l’anneau de descripteurs et la mémoire de données tant que le groupe est enregistré ; ProvidedBufferRing::unregister les restitue (désenregistre puis libère). Les buffers consommés sont rendus au groupe par la libération du guard ProvidedBuffer.

Implementations§

Source§

impl ProvidedBufferRing

Source

pub fn register( ring: &mut IoUring, group_id: u16, count: NonZeroU16, buf_size: NonZeroU32, opts: ProvidedBufferRingOptions, ) -> Result<Self, Errno>

IORING_REGISTER_PBUF_RING (22) : enregistre un groupe group_id de count buffers de buf_size octets (count puissance de 2), puis approvisionne les count buffers.

§Errors

[Errno::EINVAL] si count n’est pas une puissance de 2 ou si count × buf_size déborde ; erreurs de mmap/io_uring_register ([Errno::ENOMEM], [Errno::EEXIST] si group_id déjà pris).

Source

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

IORING_UNREGISTER_PBUF_RING (23) : désenregistre le groupe et libère l’anneau et la mémoire de données (à la consommation de self).

Sûreté par construction : un ProvidedBuffer en cours de traitement emprunte le groupe &mut — impossible de désenregistrer tant qu’il vit. Le code suivant ne compile pas :

let mut group = ProvidedBufferRing::register(
    ring, 0, NonZeroU16::new(4).unwrap(), NonZeroU32::new(64).unwrap(),
    ProvidedBufferRingOptions::default()).unwrap();
let buf = completion.into_provided_buffer(&mut group).unwrap(); // emprunte `group`
let _ = group.unregister(ring).unwrap();  // déplace `group`…
let _ = buf.id();                          // …emprunt encore vivant ⇒ ERREUR
§Errors

Erreurs de io_uring_register ([Errno::EINVAL] si le groupe n’est pas enregistré). En cas d’erreur, la mémoire est tout de même libérée.

Source

pub fn status(&self, ring: &IoUring) -> Result<ProvidedBufferRingStatus, Errno>

IORING_REGISTER_PBUF_STATUS (26) : tête courante du groupe (diagnostic / régulation).

§Errors

Erreurs de io_uring_register.

Source

pub fn group_id(&self) -> u16

Identifiant de groupe (bgid).

Source

pub fn available(&self) -> u16

Nombre de buffers actuellement disponibles (non checkout).

Trait Implementations§

Source§

impl Debug for ProvidedBufferRing

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.