fuzz_util/
lib.rs

1// Copyright 2022 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5//! A support library to allow creating arbitrary instances of certain types by
6//! providing impls of [`arbitrary::Arbitrary`].
7
8#![deny(missing_docs)]
9
10pub mod packet_formats;
11pub mod zerocopy;
12
13/// A wrapper type that can be used to generate arbitrary `A`s for fuzzing by
14/// implementing [`arbitrary::Arbitrary`] for specific types.
15///
16/// This makes it possible to generate arbitrary instances of a type even if
17/// that type doesn't impl `arbitrary::Arbitrary`.
18#[derive(Copy, Clone, Debug)]
19pub struct Fuzzed<A>(A);
20
21impl<A> Fuzzed<A> {
22    /// Produces the object created from arbitrary input.
23    pub fn into(self: Fuzzed<A>) -> A {
24        let Self(a) = self;
25        a
26    }
27}