Skip to main content

History

Struct History 

Source
pub struct History { /* private fields */ }
Expand description

The last samples of an outlet, with their numbers.

The samples have the numbers back - len .. back, with no gap. The owner gives the number of each sample at the push, and the history removes samples only from the front.

Implementations§

Source§

impl History

Source

pub fn new(limits: HistoryLimits, srate: f64, next: u64) -> History

Build an empty history. The next sample gets the number next.

Source

pub fn len(&self) -> usize

How many samples the history holds across RAM and disk.

Source

pub fn is_empty(&self) -> bool

True when the history holds no sample in RAM or on disk.

Source

pub fn bytes(&self) -> usize

The memory that the history holds in RAM now, in bytes.

Source

pub fn disk_bytes(&self) -> u64

The bytes stored in disk spool segments now. Zero when disk spooling is off or has not spilled yet.

Source

pub fn spool_dir(&self) -> Option<PathBuf>

Path of the active spool directory, if disk spilling has started.

Source

pub fn oldest(&self) -> u64

The number of the oldest sample across disk and RAM. With no sample, the number that the next sample gets.

Source

pub fn next(&self) -> u64

The number that the next sample gets.

Source

pub fn push(&mut self, s: Sample)

Add one sample. Its timestamp must be a full timestamp, not the deduced tag.

The history then removes its oldest samples (or spills them to disk when disk_bytes > 0) until it is in its limits.

Source

pub fn push_packed(&mut self, s: PackedSample)

Add one PackedSample without copying its Arc payload.

Source

pub fn read( &self, from: u64, until: u64, max: usize, out: &mut Vec<Sample>, ) -> Option<(u64, usize)>

Copy at most max samples to the end of out, from the number from, and below the number until, in order.

until is the first number that a consumer queue holds. The history also holds the samples from that number, so without the bound a resend gives a sample twice. docs/extensions.md, resend rule 5.

If from is below the oldest number, the copy starts at the oldest number. The result is the number of the first copied sample, and the count of copied samples. With no copied sample, the result is None.

Source

pub fn read_packed( &self, from: u64, until: u64, max: usize, out: &mut Vec<PackedSample>, ) -> Option<(u64, usize)>

Share at most max packed samples to the end of out (Arc clone for RAM samples, or direct read from disk segment), from from and below until.

Trait Implementations§

Source§

impl Debug for History

Source§

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

Formats the value using the given formatter. Read more

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

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.