rumeter_component/output/
file_output.rs1use std::{fs, io::Write};
2
3use crate::{Output, record::{TITLE_NAMES, RecordData}};
4
5pub struct FileOutput {
6 file: fs::File,
7}
8
9impl FileOutput {
10 pub fn new(file: fs::File) -> Self {
11 let mut f = file;
12 let s = format!("{}\n", TITLE_NAMES.join(","));
13 f.write_all(s.as_bytes()).unwrap();
14 Self { file: f }
15 }
16}
17
18impl Output for FileOutput {
19 fn write(&mut self, data: RecordData) {
20 self.file.write_all(format!("{}\n", data).as_bytes()).unwrap();
21 }
22}