Struct embassy_hal_internal::atomic_ring_buffer::Writer

source ·
pub struct Writer<'a>(/* private fields */);
Expand description

A type which can only write to a ring buffer.

Implementations§

source§

impl<'a> Writer<'a>

source

pub fn push(&mut self, f: impl FnOnce(&mut [u8]) -> usize) -> usize

Push data into the buffer in-place.

The closure f is called with a free part of the buffer, it must write some data to it and return the amount of bytes written.

source

pub fn push_one(&mut self, val: u8) -> bool

Push one data byte.

Returns true if pushed successfully.

source

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

Get a buffer where data can be pushed to.

Equivalent to Self::push_buf but returns a slice.

source

pub fn push_slices(&mut self) -> [&mut [u8]; 2]

Get up to two buffers where data can be pushed to.

Equivalent to Self::push_bufs but returns slices.

source

pub fn push_buf(&mut self) -> (*mut u8, usize)

Get a buffer where data can be pushed to.

Write data to the start of the buffer, then call push_done with however many bytes you’ve pushed.

The buffer is suitable to DMA to.

If the ringbuf is full, size=0 will be returned.

The buffer stays valid as long as no other Writer method is called and init/deinit aren’t called on the ringbuf.

source

pub fn push_bufs(&mut self) -> [(*mut u8, usize); 2]

Get up to two buffers where data can be pushed to.

Write data starting at the beginning of the first buffer, then call push_done with however many bytes you’ve pushed.

The buffers are suitable to DMA to.

If the ringbuf is full, both buffers will be zero length. If there is only area available, the second buffer will be zero length.

The buffer stays valid as long as no other Writer method is called and init/deinit aren’t called on the ringbuf.

source

pub fn push_done(&mut self, n: usize)

Mark n bytes as written and advance the write index.

Auto Trait Implementations§

§

impl<'a> Freeze for Writer<'a>

§

impl<'a> RefUnwindSafe for Writer<'a>

§

impl<'a> Send for Writer<'a>

§

impl<'a> Sync for Writer<'a>

§

impl<'a> Unpin for Writer<'a>

§

impl<'a> UnwindSafe for Writer<'a>

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>,

§

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>,

§

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.