protoflow_core/
block_runtime.rs

1// This is free and unencumbered software released into the public domain.
2
3use crate::{
4    prelude::{Duration, Instant, Range},
5    BlockError, Port,
6};
7
8pub trait BlockRuntime: Send + Sync {
9    fn is_alive(&self) -> bool;
10
11    fn sleep_for(&self, duration: Duration) -> Result<(), BlockError>;
12
13    fn sleep_until(&self, instant: Instant) -> Result<(), BlockError>; // TODO
14
15    /// Wait for a port to be connected.
16    fn wait_for(&self, port: &dyn Port) -> Result<(), BlockError>;
17
18    fn yield_now(&self) -> Result<(), BlockError>;
19
20    fn random_duration(&self, range: Range<Duration>) -> Duration;
21}