bytes icon indicating copy to clipboard operation
bytes copied to clipboard

Add optional support for the arbitrary crate

Open morr0ne opened this issue 2 months ago • 2 comments

This PRs adds optional support for the arbitrary crate by deriving the Arbitrary trait for both Bytes and BytesMut. This is incredibly useful for fuzz testing as it allows for structure aware fuzzing. Adding this traits directly allows downstream users to easily derive the traits for their structs:

E.g. from one of my projects

#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Arbitrary)]
pub struct Message {
    pub object_id: u32,
    pub opcode: u16,
    pub payload: Bytes,
}

Without bytes implementing Arbitrary directly this would require some kinda of wrapper struct.

morr0ne avatar Jun 19 '24 18:06 morr0ne