pub struct Ubend { /* private fields */ }Expand description
Circular buffer implementation that matches the C Ubend structure
§Serialization
When the serde feature is enabled, this struct can be serialized and deserialized.
This is useful for saving the state of a SPOT detector and restoring it later.
Implementations§
Source§impl Ubend
impl Ubend
Sourcepub fn new(capacity: usize) -> SpotResult<Self>
pub fn new(capacity: usize) -> SpotResult<Self>
Initialize a new Ubend with the given capacity
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Get the current size of the container Returns capacity if filled, otherwise returns cursor position
Sourcepub fn push(&mut self, x: f64) -> f64
pub fn push(&mut self, x: f64) -> f64
Push a new value into the container Returns the value that was erased (if any), otherwise NaN
Sourcepub fn get(&self, index: usize) -> Option<f64>
pub fn get(&self, index: usize) -> Option<f64>
Get the data at a specific index in insertion order
Sourcepub fn last_erased_data(&self) -> f64
pub fn last_erased_data(&self) -> f64
Get last erased data
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Ubend
impl<'de> Deserialize<'de> for Ubend
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Ubend
impl RefUnwindSafe for Ubend
impl Send for Ubend
impl Sync for Ubend
impl Unpin for Ubend
impl UnwindSafe for Ubend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more