format-ende

Crates.ioformat-ende
lib.rsformat-ende
version0.1.1
created_at2025-09-22 13:25:21.892303+00
updated_at2025-09-22 17:55:31.163257+00
descriptionSet of traits allowing to encode/decode data from/to a generic format
homepage
repositoryhttps://codeberg.org/CoffeJunkStudio/format-ende
max_upload_size
id1850026
size8,154
(dezajno)

documentation

README

format-ende

This crate defines the core traits for encoding and decoding data to/from a generic format. It provides a unified interface for various serialization formats, allowing to write code that is agnostic to the underlying format.

Example

use format_ende::FormatInfo;
use format_ende::FormatEncoder;

/// Print given value encoded with the given encoder
fn print<E, V>(encoder: &mut E, value: &V) where
    E: FormatInfo,
    E: FormatEncoder<V>,
    E::EncodeError: std::fmt::Debug,
{
    println!(
        "{} as {}:",
        std::any::type_name::<V>(),
        encoder.file_extension()
    );

    // We don't care what the underlying format is here, we just know that we want to output to stdout
    let mut stdout = std::io::stdout();
    encoder.encode(&mut stdout, value).unwrap();
    println!();
}
Commit count: 0

cargo fmt