I have written a format which supports both binary and text representations in the same crate. You can take a look for inspiration. My personal experience is that it's a lot easier to do if you stay within the same crate (because common code won't have to be pulled out to a 3rd, separate crate), and your users will probably be happier, too, because they won't have to memorize two crate names.
Not quite clear on the best way to expose the public function calls. Using the suggested form produces a name clash, because this promotes all those calls to the top level of the crate. What's the best convention on this?
pub use crate::{
de::{
binary::from_bytes,
////binary::from_reader, // Name clash
xml::from_reader,
xml::from_str,
},
ser::{
binary::to_bytes,
////binary::to_writer, // Name clash
xml::to_string,
xml::to_writer,
},
};
pub use crate::{
de::{
binary::from_bytes,
binary::from_reader as from_reader_to_binary,
xml::from_reader as from_reader_to_xml,
xml::from_str,
},
ser::{
binary::to_bytes,
binary::to_writer as to_binary_writer,
xml::to_string,
xml::to_writer as to_xml_writer,
},
};
Not clear about the naming convention here, but if you need another naming, as is what you want.