logic_mesh/base/input/input_reader.rs
1// Copyright (c) 2022-2023, Radu Racariu.
2
3use crate::base::block::Block;
4use std::time::Duration;
5
6/// Specifies the protocol for reading
7/// block inputs
8#[allow(async_fn_in_trait)]
9pub trait InputReader: Block {
10 /// Reads the connected block inputs.
11 ///
12 /// # Returns
13 /// The index of the input that received a value.
14 async fn read_inputs(&mut self) -> Option<usize>;
15
16 /// Reads the connected block inputs.
17 /// This would only complete when at least one input has data.
18 ///
19 /// # Returns
20 /// The index of the input that received a value.
21 async fn read_inputs_until_ready(&mut self) -> Option<usize>;
22
23 /// Waits for any input to have data.
24 async fn wait_on_inputs(&mut self, timeout: Duration) -> Option<usize>;
25}