Skip to main content

Reservation

Struct Reservation 

Source
pub struct Reservation<'a> { /* private fields */ }
Expand description

A wrapper around a slot of memory in the ring buffer.

A Reservation has a predetermined size that is determined by the size passed into reserve. Any attempt to write more than this amount of data into the slot is a programming error and will cause an assertion failure. This class provides a formal way for writers to serialize data in place in the ring buffer, thus eliminating the need for a temporary serialization buffer.

Implementations§

Source§

impl<'a> Reservation<'a>

Source

pub fn write(&mut self, data: &[u8]) -> Result<(), Status>

Writes the given data into this reservation.

Source

pub fn commit(self) -> Result<(), Status>

Advances the write pointer of the associated spsc buffer.

This makes the written data visible to the reader, and thus can only be called once all writes have been completed and the reservation is fully written.

Trait Implementations§

Source§

impl<'a> Debug for Reservation<'a>

Source§

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

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

impl<'a> Drop for Reservation<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Reservation<'a>

§

impl<'a> RefUnwindSafe for Reservation<'a>

§

impl<'a> Send for Reservation<'a>

§

impl<'a> Sync for Reservation<'a>

§

impl<'a> Unpin for Reservation<'a>

§

impl<'a> UnsafeUnpin for Reservation<'a>

§

impl<'a> !UnwindSafe for Reservation<'a>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.