Buffer

Struct Buffer 

Source
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

Source

pub fn capacity(&self) -> usize

Get how many samples this buffer can hold.

Source

pub fn clear(&mut self)

Clear out the buffer’s samples.

Source

pub fn len(&self) -> usize

Size of the buffer, in samples.

Source

pub fn is_empty(&self) -> bool

Returns true if there are no samples in the buffer.

Source

pub fn remaining_capacity(&self) -> usize

Remaining capacity in the buffer, in samples.

Source

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.
Source

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.
Source

pub fn push(&mut self, val: ComplexI8)

Push a value onto the buffer.

§Panics
  • If there is no space left in the buffer.
Source

pub fn bytes(&self) -> &[u8]

Get the sample sequence as a slice of bytes instead of complex values.

Source

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

Get the sample sequence as a mutable slice of bytes instead of complex values.

Source

pub fn samples(&self) -> &[ComplexI8]

Get the samples in the buffer.

Source

pub fn samples_mut(&mut self) -> &mut [ComplexI8]

Mutably get the samples in the buffer.

Trait Implementations§

Source§

impl Drop for Buffer

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Buffer

§

impl RefUnwindSafe for Buffer

§

impl Send for Buffer

§

impl Sync for Buffer

§

impl Unpin for Buffer

§

impl UnwindSafe for Buffer

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

Source§

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

Source§

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.