| 12 | pub const DEFAULT_FORMAT: &str = JsonId; |
| 13 | |
| 14 | pub trait Format { |
| 15 | fn add_arguments<'a>(&self, args: clap::Command<'a>) -> clap::Command<'a>; |
| 16 | fn set_arguments(&mut self, matches: &clap::ArgMatches) -> Result<(), Error>; |
| 17 | fn get_extensions(&self) -> &'static [&'static str]; |
| 18 | fn is_valid_header(&self, header: &[u8]) -> Result<bool, Error>; |
| 19 | fn parse(&self, input: &mut dyn Read) -> Result<serde_json::Value, Error>; |
| 20 | fn write(&self, values: Vec<serde_json::Value>) -> Result<(), Error>; |
| 21 | } |
| 22 | |
| 23 | pub fn load_formats() -> IndexMap<&'static str, Box<dyn Format>> { |
| 24 | let mut formats: IndexMap<&'static str, Box<dyn Format>> = IndexMap::new(); |