Skip to main content

paiagram_core/
export.rs

1use bevy::prelude::*;
2
3pub mod graphviz;
4pub mod oudia;
5// pub mod typst_timetable;
6
7pub trait ExportObject {
8    /// Export contents to a `Vec<u8>` buffer, with optional parameters
9    fn export_to_buffer(&mut self, buffer: &mut Vec<u8>);
10    /// Export contents and save them on disk, with optional parameters
11    fn export_to_file(&mut self) {
12        let mut buffer = Vec::new();
13        self.export_to_buffer(&mut buffer);
14        let mut filename = String::new();
15        filename.push_str(self.filename().as_ref());
16        filename.push_str(self.extension().as_ref());
17        paiagram_rw::write::write_file(filename, move |writer| writer.write_all(&buffer));
18    }
19    /// the filename
20    fn filename(&self) -> impl AsRef<str> {
21        "exported_file"
22    }
23    /// The extension name with the dot
24    fn extension(&self) -> impl AsRef<str>;
25}