libtest2_harness/notify/json.rs
1use super::Event;
2
3#[derive(Debug)]
4pub(crate) struct JsonNotifier<W> {
5 writer: W,
6}
7
8impl<W: std::io::Write> JsonNotifier<W> {
9 pub(crate) fn new(writer: W) -> Self {
10 Self { writer }
11 }
12}
13
14impl<W: std::io::Write> super::Notifier for JsonNotifier<W> {
15 fn notify(&mut self, event: Event) -> std::io::Result<()> {
16 let event = event.to_jsonline();
17 writeln!(self.writer, "{event}")?;
18 Ok(())
19 }
20}