[][src]Struct spsc_bip_buffer::BipBufferWriterReservation

pub struct BipBufferWriterReservation<'a> { /* fields omitted */ }

A write reservation returned by reserve or spin_reserve. The sender can access the reserved buffer slice by dererferencing this reservation. Its size is guaranteed to match the requested length in reserve or spin_reserve.

There are no guarantees on the contents of the buffer slice when a new reservation is created: the slice may contain stale data or garbage.

Dropping the reservation (or calling send, which consumes self) marks the end of the write and informs the reader that the data in this slice can now be read.

Don't drop the reservation before you're done writing!

Examples

use spsc_bip_buffer::bip_buffer_from;
let (mut writer, _) = bip_buffer_from(vec![0u8; 1024]);
std::thread::spawn(move || {
  let mut reservation = writer.spin_reserve(4);
  reservation[0] = 0xf0;
  reservation[1] = 0x0f;
  reservation[2] = 0x00;
  reservation[3] = 0xee;
  reservation.send();
}).join().unwrap();
use spsc_bip_buffer::bip_buffer_from;
let (mut writer, _) = bip_buffer_from(vec![0u8; 1024]);
std::thread::spawn(move || {
  let mut reservation = writer.spin_reserve(4);
  let data = vec![0xf0, 0x0f, 0x00, 0xee];
  reservation.copy_from_slice(&data[..]);
  // drop reservation, which sends data
}).join().unwrap();

Methods

impl<'a> BipBufferWriterReservation<'a>[src]

pub fn send(self)[src]

Calling send (or simply dropping the reservation) marks the end of the write and informs the reader that the data in this slice can now be read.

Trait Implementations

impl<'a> Drop for BipBufferWriterReservation<'a>[src]

impl<'a> Deref for BipBufferWriterReservation<'a>[src]

type Target = [u8]

The resulting type after dereferencing.

impl<'a> DerefMut for BipBufferWriterReservation<'a>[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]