Trait Serializer

Source
pub trait Serializer {
    type Value;

    // Required methods
    fn extension(&self) -> &str;
    fn from_data(&self, data: &[u8]) -> Option<Self::Value>;
    fn to_data(&self, value: &Self::Value) -> Vec<u8> ;
}
Expand description

A Serializer is used to encode and decode test cases into bytes.

It is used to transfer test cases between the corpus on the file system and the fuzzer’s storage.

Required Associated Types§

Source

type Value

The type of the value to be serialized

Required Methods§

Source

fn extension(&self) -> &str

The extension of the file containing the serialized value

Source

fn from_data(&self, data: &[u8]) -> Option<Self::Value>

Deserialize the bytes into the value.

This method can fail by returning None

Source

fn to_data(&self, value: &Self::Value) -> Vec<u8>

Serialize the value into bytes

This method should never fail.

Implementors§

Source§

impl Serializer for ByteSerializer

Source§

impl<S> Serializer for SerdeSerializer<S>
where S: Serialize + for<'e> Deserialize<'e>,

Source§

type Value = S

Source§

impl<StringType> Serializer for StringSerializer<StringType>
where StringType: ToString + FromStr,

Source§

type Value = StringType