pub trait ExportSink {
// Required methods
fn write(&mut self, memory: &ExportableMemory) -> Result<()>;
fn finalize(self: Box<Self>) -> Result<()>;
}Expand description
Sink for exported memories.
Implementations write memories to a specific format (JSON, YAML, CSV, etc.).
§Lifecycle
- Create sink with output destination
- Call
write()for each memory - Call
finalize()to complete the export
§Example Implementation
ⓘ
impl ExportSink for JsonSink {
fn write(&mut self, memory: &ExportableMemory) -> Result<()> {
serde_json::to_writer(&mut self.writer, memory)?;
writeln!(self.writer)?;
Ok(())
}
fn finalize(self: Box<Self>) -> Result<()> {
self.writer.flush()?;
Ok(())
}
}