You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
914 B
33 lines
914 B
//! The available formats to convert
|
|
use super::*;
|
|
use std::io;
|
|
use object::{
|
|
Object, OwnedObject,
|
|
};
|
|
|
|
pub struct Config;
|
|
|
|
/// A directive for a format on how to encode and decode objects.
|
|
#[derive(Clone, Copy)]
|
|
pub struct FormatDirective
|
|
{
|
|
encode: fn (&Config, &mut dyn io::Write, &dyn Object) -> io::Result<usize>,
|
|
decode: fn (&Config, &mut dyn io::Read) -> io::Result<(OwnedObject<'static>, usize)>,
|
|
}
|
|
|
|
macro_rules! directive {
|
|
($($name:literal),+ => $encode:expr, $decode:expr) => {
|
|
(&[$($name),+], FormatDirective {
|
|
encode: $encode,
|
|
decode: $decode,
|
|
})
|
|
};
|
|
}
|
|
|
|
/// All format directives and their name(s)
|
|
pub static FORMATS: &[(&'static [&'static str], FormatDirective)] = &[
|
|
directive!("json" => |_, _, _| todo!(), |_, _| todo!()),
|
|
directive!("s-expression", "sexpr" => |_, _, _| todo!(), |_, _| todo!()),
|
|
directive!("cbor" => |_, _, _| todo!(), |_, _| todo!()),
|
|
];
|