Skip to main content

GCDatapointState

Struct GCDatapointState 

pub struct GCDatapointState {
    latest_value: DatapointBuffering,
    has_data: AtomicBool,
}
Expand description

A store for datapoints that are updated in realtime.

Fields§

§latest_value: DatapointBuffering§has_data: AtomicBool

Implementations§

§

impl GCDatapointState

pub(crate) fn new(capacity: u64) -> Self

Creates a new datapoint state that keeps the last capacity values.

If the capacity is less than or equal to 1, it will behave as a realtime datapoint, just keeping the latest value. Else, it will keep the last capacity values.

pub(crate) fn new_realtime() -> Self

Creates a new datapoint state that just keeps the latest value.

pub fn clear(&mut self)

Set’s the datapoint state to the default one.

pub fn is_initialized(&self) -> bool

This should be an atomic operation and is dependant on the crate::GCRealtimeDatabase. This assumes that once the has_data flag is set to true, the value will not be changed. It provides a way for the caller to check if the datapoint has been initialized without the need of synchronization mechanism.

pub fn update_value(&mut self, value: GCArc<GCDatapointValue>)

Updates the value of the datapoint

pub fn get_buffered_data( &self, ) -> Option<impl Iterator<Item = &GCArc<GCDatapointValue>>>

Returns the last n datapoints

pub fn get_latest_value(&self) -> &GCArc<GCDatapointValue>

Returns the latest value of the datapoint

Trait Implementations§

§

impl Clone for GCDatapointState

§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Default for GCDatapointState

§

fn default() -> Self

Returns the “default value” for a type. Read more
§

impl Send for GCDatapointState

§

impl Sync for GCDatapointState

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.