iridis_node/primitives/
raw_input.rs

1//! This module contains implementations for this primitive.
2
3use crate::prelude::*;
4
5/// Not typed Input to receive data from the dataflow
6#[derive(Debug)]
7pub struct RawInput {
8    /// The receiver part of the MPSC channel
9    pub rx: MessageReceiver,
10
11    /// The source node layout, useful for debugging
12    pub source: NodeID,
13    /// The layout of the input, useful for debugging
14    pub layout: InputID,
15}
16
17impl RawInput {
18    /// Create a new RawInput instance
19    pub fn new(rx: MessageReceiver, source: NodeID, layout: InputID) -> Self {
20        Self { rx, source, layout }
21    }
22
23    /// Receive a message from the channel, asynchronously
24    pub async fn recv(&mut self) -> Result<DataflowMessage> {
25        let message = self
26            .rx
27            .recv()
28            .await
29            .ok_or_eyre(report_error_receiving(&self.source, &self.layout))?;
30
31        Ok(message)
32    }
33}