1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use crate::runtime::dev::prelude::*;
/// Forward messages.
///
/// # Message Inputs
///
/// `in`: Messages to forward. `Pmt::Finished` terminates the block.
///
/// # Message Outputs
///
/// `out`: Forwarded messages.
///
/// # Usage
/// ```
/// use futuresdr::blocks::MessageCopy;
///
/// let copy = MessageCopy::new();
/// ```
#[derive(Block)]
#[message_inputs(r#in)]
#[message_outputs(out)]
#[null_kernel]
pub struct MessageCopy;
impl MessageCopy {
/// Create MessageCopy block
pub fn new() -> Self {
Self
}
async fn r#in(
&mut self,
io: &mut WorkIo,
mo: &mut MessageOutputs,
_meta: &mut BlockMeta,
p: Pmt,
) -> Result<Pmt> {
match p {
Pmt::Finished => {
io.finished = true;
}
p => {
mo.post("out", p).await?;
}
}
Ok(Pmt::Ok)
}
}
impl Default for MessageCopy {
fn default() -> Self {
Self::new()
}
}