hal-common/atomic_ring_buffer: Add push_slice, pop_slice.
This commit is contained in:
parent
feaeb533fb
commit
5b72410828
@ -135,6 +135,14 @@ impl<'a> Writer<'a> {
|
|||||||
n != 0
|
n != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a buffer where data can be pushed to.
|
||||||
|
///
|
||||||
|
/// Equivalent to [`Self::push_buf`] but returns a slice.
|
||||||
|
pub fn push_slice(&mut self) -> &mut [u8] {
|
||||||
|
let (data, len) = self.push_buf();
|
||||||
|
unsafe { slice::from_raw_parts_mut(data, len) }
|
||||||
|
}
|
||||||
|
|
||||||
/// Get a buffer where data can be pushed to.
|
/// Get a buffer where data can be pushed to.
|
||||||
///
|
///
|
||||||
/// Write data to the start of the buffer, then call `push_done` with
|
/// Write data to the start of the buffer, then call `push_done` with
|
||||||
@ -204,6 +212,14 @@ impl<'a> Reader<'a> {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a buffer where data can be popped from.
|
||||||
|
///
|
||||||
|
/// Equivalent to [`Self::pop_buf`] but returns a slice.
|
||||||
|
pub fn pop_slice(&mut self) -> &mut [u8] {
|
||||||
|
let (data, len) = self.pop_buf();
|
||||||
|
unsafe { slice::from_raw_parts_mut(data, len) }
|
||||||
|
}
|
||||||
|
|
||||||
/// Get a buffer where data can be popped from.
|
/// Get a buffer where data can be popped from.
|
||||||
///
|
///
|
||||||
/// Read data from the start of the buffer, then call `pop_done` with
|
/// Read data from the start of the buffer, then call `pop_done` with
|
||||||
|
Loading…
Reference in New Issue
Block a user