//! The available formats to convert use super::*; use processor::Processor; /// All formats and their associated processor pub enum Format { Json(processor::Json), SExpr(processor::Sexpr), CBor(processor::Cbor), } impl Format { /// The processor for this format pub fn processor(&self) -> &(dyn Processor + 'static) { match &self { Self::Json(a) => a, Self::SExpr(a) => a, Self::CBor(a) => a, } } /// The processor for this format pub fn processor_mut(&mut self) -> &mut (dyn Processor + 'static) { match self { Self::Json(a) => a, Self::SExpr(a) => a, Self::CBor(a) => a, } } } /// All format objects and their name(s) pub static FORMATS: &[(&'static [&'static str], Format)] = &[ (&["json"], Format::Json(processor::Json)), (&["s-expression", "sexpr"], Format::SExpr(processor::Sexpr)), (&["cbor"], Format::CBor(processor::Cbor)), ];