Recording

Struct Recording 

Source
pub struct Recording<S> { /* private fields */ }
Expand description

A thread-safe recording of stream items with optional capacity limits.

Recording stores items with their timing information and can be shared across threads. It supports bounded or unbounded storage.

Implementations§

Source§

impl<S> Recording<S>

Source

pub fn new() -> Self

Creates a new unbounded recording.

Source

pub fn from_items(items: impl IntoIterator<Item = RecordedItem<S>>) -> Self

Creates a recording from a sequence of recorded items.

Source

pub fn from_raw_items(items: impl IntoIterator<Item = S>) -> Self

Creates a recording from a sequence of items.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a recording that keeps only the last capacity items. Older items are dropped as new ones arrive.

Source

pub async fn save(&self, path: impl AsRef<Path>) -> Result<()>
where S: Serialize,

Saves the recording to disk with timing information.

Source

pub async fn load(path: impl AsRef<Path>) -> Result<Self>
where S: for<'de> Deserialize<'de>,

Loads a recording from disk.

Source§

impl<S: Clone> Recording<S>

Source

pub fn items(&self) -> Vec<S>

Returns the items in the recording.

Source

pub fn replay(&self) -> impl Stream<Item = S>

Replays items with original timing delays between them.

Source

pub fn replay_from(&self, start_seq: u64) -> impl Stream<Item = S>

Replays items starting from sequence number start_seq. Timing between replayed items is preserved.

Source

pub fn replay_since(&self, since: SystemTime) -> impl Stream<Item = S>

Replays items recorded after since. Timing between replayed items is preserved.

Source

pub fn replay_range(&self, start: u64, end: u64) -> impl Stream<Item = S>

Replays items within the sequence range [start, end] (inclusive). Timing between replayed items is preserved.

Source

pub fn replay_with_speed(&self, speed: Speed) -> impl Stream<Item = S>

Replays with adjusted timing. Speed of 2.0 is twice as fast, 0.5 is half the speed. Relative timing between replayed items is preserved.

Source

pub fn replay_immediate(&self) -> impl Stream<Item = S>

Replays items immediately without any delays. Useful for tests that don’t care about timing.

Trait Implementations§

Source§

impl<S: Clone> Clone for Recording<S>

Source§

fn clone(&self) -> Recording<S>

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
Source§

impl<S: Debug> Debug for Recording<S>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S> Default for Recording<S>

Source§

fn default() -> Self

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

impl<'de, S> Deserialize<'de> for Recording<S>
where S: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<S> Serialize for Recording<S>
where S: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Recording<S>

§

impl<S> !RefUnwindSafe for Recording<S>

§

impl<S> Send for Recording<S>
where S: Sync + Send,

§

impl<S> Sync for Recording<S>
where S: Sync + Send,

§

impl<S> Unpin for Recording<S>

§

impl<S> !UnwindSafe for Recording<S>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,