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
use async_trait::async_trait;
use std::{convert::Infallible, fmt::Write};
use super::TransformEntry;
use crate::{
action::transform::result::TransformedEntry,
entry::Entry,
sink::{Sink, Stdout},
};
#[derive(Debug)]
pub struct DebugPrint;
#[async_trait]
impl TransformEntry for DebugPrint {
type Err = Infallible;
async fn transform_entry(&self, entry: Entry) -> Result<Vec<TransformedEntry>, Self::Err> {
let mut msg = entry.msg;
msg.body = {
let mut body = msg.body.unwrap_or_else(|| "None".to_owned());
_ = write!(
body,
"\n\nid: {:?}\n\nraw_contents: {:?}",
entry.id, entry.raw_contents
);
Some(body)
};
Stdout
.send(msg, None, Some("debug print"))
.await
.expect("stdout is unavailable");
Ok(Vec::new())
}
}