From ad442d6678430426c05a391c447f4275557b46bd Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 28 May 2021 00:07:35 +0100 Subject: [PATCH] formats individual skel --- src/formats.rs | 8 ++++++-- src/formats/cbor.rs | 14 ++++++++++++++ src/formats/sexpr.rs | 14 ++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 src/formats/cbor.rs create mode 100644 src/formats/sexpr.rs diff --git a/src/formats.rs b/src/formats.rs index 27694aa..14c91e3 100644 --- a/src/formats.rs +++ b/src/formats.rs @@ -9,6 +9,10 @@ use object::Object; /// `Format` impl for JSON. mod json; +/// `Format` impl for S expressions. +mod sexpr; +/// `Format` impl for CBOR. +mod cbor; /// Config for the encode/decode #[derive(Debug)] @@ -54,8 +58,8 @@ macro_rules! directive { /// All format directives and their name(s) pub static FORMATS: &[(&'static [&'static str], FormatDirective)] = &[ directive!(for json::JsonFormatter => "json", "js", "javascript"), - directive!("s-expression", "sexpr", "lisp", "lexpr" => |_, _, _| todo!(), |_, _| todo!()), - directive!("cbor" => |_, _, _| todo!(), |_, _| todo!()), + directive!(for sexpr::SExpressionFormatter => "s-expression", "sexpr", "lisp", "lexpr"), + directive!(for cbor::CborFormatter => "cbor"), ]; /// A formatting error kind. See `Error`. diff --git a/src/formats/cbor.rs b/src/formats/cbor.rs new file mode 100644 index 0000000..0c924f6 --- /dev/null +++ b/src/formats/cbor.rs @@ -0,0 +1,14 @@ +use super::*; + +#[derive(Debug)] +pub struct CborFormatter; + +impl Format for CborFormatter +{ + fn encode(cfg: &Config, to: W, obj: &Object) -> Result { + todo!() + } + fn decode(cfg: &Config, from: R) -> Result { + todo!() + } +} diff --git a/src/formats/sexpr.rs b/src/formats/sexpr.rs new file mode 100644 index 0000000..8bdb444 --- /dev/null +++ b/src/formats/sexpr.rs @@ -0,0 +1,14 @@ +use super::*; + +#[derive(Debug)] +pub struct SExpressionFormatter; + +impl Format for SExpressionFormatter +{ + fn encode(cfg: &Config, to: W, obj: &Object) -> Result { + todo!() + } + fn decode(cfg: &Config, from: R) -> Result { + todo!() + } +}