1use melodium_core::*;
2use melodium_macro::{check, mel_function, mel_treatment};
3
4#[mel_treatment(
6 input value Stream<bool>
7 output iter Stream<void>
8)]
9pub async fn to_void() {
10 while let Ok(values) = value.recv_bool().await {
11 check!(iter.send_void(vec![(); values.len()]).await)
12 }
13}
14
15#[mel_function]
19pub fn to_byte(value: bool) -> Vec<byte> {
20 vec![match value {
21 true => 1,
22 false => 0,
23 }]
24}
25
26#[mel_treatment(
32 input value Stream<bool>
33 output data Stream<Vec<byte>>
34)]
35pub async fn to_byte() {
36 while let Ok(values) = value.recv_bool().await {
37 check!(
38 data.send_vec_byte(
39 values
40 .into_iter()
41 .map(|val| vec![match val {
42 true => 1,
43 false => 0,
44 }])
45 .collect()
46 )
47 .await
48 )
49 }
50}