Trait countroo::Exportable

source ·
pub trait Exportable {
    // Required method
    fn export(&self, writer: Box<dyn OutputWriter>) -> Result<(), Error>;
}
Expand description

Exportable 📤 - Making Your Data Dance Across the Output!

A trait for the adventurous Rustaceans who want their data to leap out of the console and into the wild! Implement Exportable to enable your structs to export their data, whether it’s to a file, a terminal, or across the seven seas of your application. 🌊📄

§Functionality

  • export: Takes your data on a journey from the internal state to an external representation, allowing it to be written, viewed, and shared far and wide. 🌍

§Requirements

Implementors must define how their data is exported, providing a writer that adheres to the OutputWriter trait. This writer handles the specifics of the output format and destination.

§Example

use countroo::prelude::*;
struct MyExportableData {
    // Your data fields here
}

impl Exportable for MyExportableData {
    fn export(&self, writer: Box<dyn OutputWriter>) -> Result<(), std::io::Error> {
        // Implement how your data is written using the provided writer
        // For example, converting your data to JSON, CSV, or plain text
        todo!("Implement the export logic here")
    }
}

With Exportable, your data isn’t just stored; it’s a story waiting to be told.

Required Methods§

source

fn export(&self, writer: Box<dyn OutputWriter>) -> Result<(), Error>

Implementors§