Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional support for the arbitrary crate #715

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

morr0ne
Copy link

@morr0ne morr0ne commented Jun 19, 2024

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.

@seanmonstar
Copy link
Member

Thanks for the PR! However, I wouldn't want to add this public dependency to bytes.

@morr0ne
Copy link
Author

morr0ne commented Jun 19, 2024

Thanks for the PR! However, I wouldn't want to add this public dependency to bytes.

What's the issue with having arbitrary as a depedency? It is optional and not enabled by default just like serde

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants