Crate sturgeon

Crate sturgeon 

Source
Expand description

A library for recording and replaying asynchronous streams with timing information.

This crate provides utilities to record items from any Stream along with their timing information, and replay them later with the same timing characteristics.

§Examples

§Basic Recording and Replay

use sturgeon::record;
use futures::{stream, StreamExt};

let stream = stream::iter(vec![1, 2, 3]);
let mut recorded = record(stream);

while let Some(item) = recorded.next().await {
    println!("Got: {}", item);
}

// Get the recording and replay with original timing
let recording = recorded.recording();
let replay = recording.replay();
tokio::pin!(replay);
while let Some(item) = replay.next().await {
    println!("Replayed: {}", item);
}

§Speed-Controlled Replay

use sturgeon::{record, Speed};
use futures::{stream, StreamExt};

let stream = stream::iter(vec![1, 2, 3]);
let mut recorded = record(stream);

while recorded.next().await.is_some() {}

let recording = recorded.recording();

// Replay at 2x speed
let fast = recording.replay_with_speed(Speed::new(2.0).unwrap());

// Replay at half speed
let slow = recording.replay_with_speed(Speed::new(0.5).unwrap());

Structs§

RecordedItem
A single recorded item with timing information.
RecordedStream
A stream wrapper that records all items passing through it.
Recording
A thread-safe recording of stream items with optional capacity limits.
Speed
A positive playback speed multiplier

Enums§

Error
Errors that can occur when working with recorded streams.

Functions§

record
Wraps a stream to record all items with timing information. The stream passes through - items are cloned for recording.
record_with_capacity
Like record but only keeps the last capacity items in memory. Useful for long-running streams where full history isn’t needed.

Type Aliases§

SturgeonResult
Result type for sturgeon operations.