pub struct Buffer { /* private fields */ }Expand description
A Buffer holding HackRF transfer data.
Samples can be directly accessed as slices, and can be extended up to the length of the fixed-size underlying buffer.
When dropped, this buffer returns to the internal buffer pool it came from. It can either be backed by an allocation from the system allocator, or by some platform-specific way of allocating memory for zero-copy USB transfers.
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn remaining_capacity(&self) -> usize
pub fn remaining_capacity(&self) -> usize
Remaining capacity in the buffer, in samples.
Sourcepub fn extend_zeros(&mut self, len: usize) -> &mut [ComplexI8] ⓘ
pub fn extend_zeros(&mut self, len: usize) -> &mut [ComplexI8] ⓘ
Extend the buffer with some number of samples set to 0, and get a mutable slice to the newly initialized samples.
§Panics
- If there is not enough space left for the added samples.
Sourcepub fn extend_from_slice(&mut self, slice: &[ComplexI8])
pub fn extend_from_slice(&mut self, slice: &[ComplexI8])
Extend the buffer with a slice of samples.
§Panics
- If there is no space left in the buffer for the slice.
Sourcepub fn bytes(&self) -> &[u8] ⓘ
pub fn bytes(&self) -> &[u8] ⓘ
Get the sample sequence as a slice of bytes instead of complex values.
Sourcepub fn bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn bytes_mut(&mut self) -> &mut [u8] ⓘ
Get the sample sequence as a mutable slice of bytes instead of complex values.
Sourcepub fn samples_mut(&mut self) -> &mut [ComplexI8] ⓘ
pub fn samples_mut(&mut self) -> &mut [ComplexI8] ⓘ
Mutably get the samples in the buffer.