extern crate fuzzcheck_traits;
#[cfg(feature = "serde-json")]
mod serde_serializer;
#[cfg(feature = "serde-json")]
pub use serde_serializer::SerdeSerializer;
#[cfg(feature = "serde-json-alternative")]
mod json_serializer;
#[cfg(feature = "serde-json-alternative")]
pub use json_serializer::JsonSerializer;
pub struct ByteSerializer {
ext: &'static str,
}
impl ByteSerializer {
pub fn new(ext: &'static str) -> Self {
Self { ext }
}
}
impl fuzzcheck_traits::Serializer for ByteSerializer {
type Value = Vec<u8>;
fn is_utf8(&self) -> bool {
false
}
fn extension(&self) -> &str {
self.ext
}
fn from_data(&self, data: &[u8]) -> Option<Self::Value> {
Some(data.into())
}
fn to_data(&self, value: &Self::Value) -> Vec<u8> {
value.clone()
}
}