bytes
bytes copied to clipboard
Add optional support for the arbitrary crate
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.