pub fn convert(
from: Format,
to: Format,
input: &str,
) -> Result<String, Box<dyn Error>>Expand description
Converts input from one format to another via the canonical hub.
If from equals to, the input is returned unchanged. That preserves
BOM markers, formatting, and other byte-level details that a round-trip
through the hub would normalize away.
§Errors
Returns an error if the input cannot be parsed as from or serialized
as to, or if the document cannot be represented in the target format
(for example, nested values when converting to CSV).
§Examples
use sheeter_engine::{convert, Format};
let json = convert(Format::Csv, Format::Json, "a\n1\n").unwrap();
assert_eq!(json, r#"[{"a":"1"}]"#);