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>
impl<'a> Run<'a>
Sourcepub fn of<T: SensorData>(
base_timestamp: u64,
interval: u64,
samples: &'a [T],
) -> Result<Self, Error>
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.
Sourcepub fn base_timestamp(&self) -> u64
pub fn base_timestamp(&self) -> u64
Timestamp of the first sample, which is the entry header’s timestamp.
Sourcepub fn payload_len(&self) -> usize
pub fn payload_len(&self) -> usize
Bytes the run occupies as an entry payload.