Skip to main content

Run

Struct Run 

Source
pub struct Run<'a> { /* private fields */ }
Expand description

Evenly spaced samples of one sensor, ready to be appended as a single entry.

Construct with Run::of, which validates everything an appender would otherwise have to re-check, and hand it to append_run:

ⓘ
use sensor_db::{LogSink, Run};

let burst: [Temperature; 32] = collect_burst();
db.append_run(&Run::of(t0, 10_000, &burst)?)?;

The samples are borrowed, not copied: the driver writes the frame header and then the sample bytes straight into its page buffer.

Implementations§

Source§

impl<'a> Run<'a>

Source

pub fn of<T: SensorData>( base_timestamp: u64, interval: u64, samples: &'a [T], ) -> Result<Self, Error>

Describe a run of T values, the first at base_timestamp and each subsequent one interval later.

§Errors

Error::InvalidRun if samples is empty or longer than u16::MAX, if T is zero-sized, if the last sample’s timestamp would overflow u64, or if the frame would exceed the u16 payload length the entry header can carry. Whether it fits a page is the appending log’s question, and it answers Error::PayloadTooLarge.

Source

pub fn sensor_id(&self) -> u16

The sensor id the samples are stored under.

Source

pub fn base_timestamp(&self) -> u64

Timestamp of the first sample, which is the entry header’s timestamp.

Source

pub fn interval(&self) -> u64

Timestamp step between consecutive samples.

Source

pub fn count(&self) -> u32

How many samples the run holds; never zero.

Source

pub fn span_end(&self) -> u64

Timestamp of the last sample.

Source

pub fn payload_len(&self) -> usize

Bytes the run occupies as an entry payload.

Trait Implementations§

Source§

impl<'a> Clone for Run<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Run<'a>

Source§

impl<'a> Debug for Run<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Run<'a>

§

impl<'a> RefUnwindSafe for Run<'a>

§

impl<'a> Send for Run<'a>

§

impl<'a> Sync for Run<'a>

§

impl<'a> Unpin for Run<'a>

§

impl<'a> UnsafeUnpin for Run<'a>

§

impl<'a> UnwindSafe for Run<'a>

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.