Lines Matching full:derive
64 //! You should generally derive these marker traits whenever possible.
104 //! - **`derive`**
105 //! Provides derives for the core marker traits via the `zerocopy-derive`
107 //! necessary to depend on `zerocopy-derive` directly.
110 //! depend on both `zerocopy` and `zerocopy-derive` in your `Cargo.toml`,
112 //! so, do *not* enable the `derive` feature, and list both dependencies in
118 //! zerocopy-derive = "0.X"
122 //! one of your dependencies enables zerocopy's `derive` feature, import
335 // This is a hack to allow zerocopy-derive derives to work in this crate. They
338 #[cfg(any(feature = "derive", test))]
438 #[cfg(all(any(feature = "derive", test), zerocopy_unstable_linux))]
442 /// This derive analyzes various aspects of a type's layout that are needed for
448 /// #[derive(KnownLayout)]
455 /// #[derive(KnownLayout)]
463 /// #[derive(KnownLayout)]
474 /// This derive cannot currently be applied to unsized structs without an
477 /// Some invocations of this derive run afoul of a [known bug] in Rust's type
484 /// #[derive(KnownLayout)]
491 /// #[derive(KnownLayout)]
494 /// #[derive(KnownLayout)]
504 /// 3 | #[derive(KnownLayout)]
510 /// = note: this error originates in the derive macro `KnownLayout` (in Nightly builds, run with…
513 /// This issue arises when `#[derive(KnownLayout)]` is applied to `repr(C)`
523 /// #[derive(KnownLayout)]
530 /// #[derive(KnownLayout)]
534 /// #[derive(KnownLayout)]
539 #[cfg(any(feature = "derive", test))]
540 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))]
571 /// [`#[derive(KnownLayout)]`][derive]; e.g.:
575 /// #[derive(KnownLayout)]
582 /// #[derive(KnownLayout)]
589 /// #[derive(KnownLayout)]
598 /// This derive performs a sophisticated analysis to deduce the layout
599 /// characteristics of types. You **must** implement this trait via the derive.
745 #[cfg_attr(feature = "derive", doc = "[derive]: zerocopy_derive::KnownLayout")]
747 not(feature = "derive"),
748 …doc = concat!("[derive]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocopy/derive.…
752 diagnostic::on_unimplemented(note = "Consider adding `#[derive(KnownLayout)]` to `{Self}`")
1360 /// This derive analyzes, at compile time, whether the annotated type satisfies
1362 /// supertraits if it is sound to do so. This derive can be applied to structs,
1367 /// #[derive(FromZeros)]
1374 /// #[derive(FromZeros)]
1383 /// #[derive(FromZeros, Immutable)]
1396 /// *This section describes, roughly, the analysis performed by this derive to
1398 /// Unless you are modifying the implementation of this derive, or attempting to
1402 /// If a type has the following properties, then this derive can implement
1416 /// implementation details of this derive.
1422 /// Neither this derive, nor the [safety conditions] of `FromZeros`, requires
1448 #[cfg(any(feature = "derive", test))]
1449 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))]
1453 /// This derive analyzes, at compile time, whether the annotated type satisfies
1455 /// sound to do so. This derive can be applied to structs, enums, and unions;
1460 /// #[derive(Immutable)]
1467 /// #[derive(Immutable)]
1475 /// #[derive(Immutable)]
1486 /// *This section describes, roughly, the analysis performed by this derive to
1488 /// Unless you are modifying the implementation of this derive, you don't need
1491 /// If a type has the following properties, then this derive can implement
1498 /// implementation details of this derive.
1501 #[cfg(any(feature = "derive", test))]
1502 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))]
1513 /// [`#[derive(Immutable)]`][derive] (requires the `derive` Cargo feature);
1518 /// #[derive(Immutable)]
1525 /// #[derive(Immutable)]
1532 /// #[derive(Immutable)]
1541 /// This derive performs a sophisticated, compile-time safety analysis to
1562 feature = "derive",
1563 doc = "[derive]: zerocopy_derive::Immutable",
1564 doc = "[derive-analysis]: zerocopy_derive::Immutable#analysis"
1567 not(feature = "derive"),
1568 …doc = concat!("[derive]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocopy/derive.…
1569 …doc = concat!("[derive-analysis]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocop…
1573 diagnostic::on_unimplemented(note = "Consider adding `#[derive(Immutable)]` to `{Self}`")
1586 /// This derive synthesizes the runtime checks required to check whether a
1588 /// This derive can be applied to structs, enums, and unions; e.g.:
1592 /// #[derive(TryFromBytes)]
1599 /// #[derive(TryFromBytes)]
1608 /// #[derive(TryFromBytes, Immutable)]
1626 /// #[derive(TryFromBytes)]
1638 #[cfg(any(feature = "derive", test))]
1639 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))]
1654 /// [`#[derive(TryFromBytes)]`][derive]; e.g.:
1658 /// #[derive(TryFromBytes)]
1665 /// #[derive(TryFromBytes)]
1674 /// #[derive(TryFromBytes, Immutable)]
1683 /// This derive ensures that the runtime check of whether bytes correspond to a
1684 /// valid instance is sound. You **must** implement this trait via the derive.
1736 #[cfg_attr(feature = "derive", doc = "[derive]: zerocopy_derive::TryFromBytes")]
1738 not(feature = "derive"),
1739 …doc = concat!("[derive]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocopy/derive.…
1743 diagnostic::on_unimplemented(note = "Consider adding `#[derive(TryFromBytes)]` to `{Self}`")
1805 /// #[derive(TryFromBytes, Immutable, KnownLayout)]
1822 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
1827 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
1831 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
1926 /// #[derive(TryFromBytes, Immutable, KnownLayout)]
1943 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
1948 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
1952 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2036 /// #[derive(TryFromBytes, Immutable, KnownLayout)]
2053 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2058 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2062 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2146 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2164 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2169 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2173 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2252 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2270 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2275 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2279 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2352 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2370 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2375 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2379 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2445 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2450 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2454 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2485 /// #[derive(TryFromBytes, Immutable, KnownLayout)]
2565 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2570 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2574 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2606 /// #[derive(TryFromBytes, Immutable, KnownLayout)]
2673 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2678 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2682 /// #[derive(TryFromBytes, KnownLayout, Immutable)]
2714 /// #[derive(TryFromBytes, Immutable, KnownLayout)]
2779 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2784 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2788 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2823 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2888 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2893 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2897 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2934 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2988 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2993 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2997 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
3034 /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
3077 /// #[derive(TryFromBytes)]
3082 /// #[derive(TryFromBytes)]
3086 /// #[derive(TryFromBytes)]
3153 /// #[derive(TryFromBytes)]
3158 /// #[derive(TryFromBytes)]
3162 /// #[derive(TryFromBytes)]
3232 /// #[derive(TryFromBytes)]
3237 /// #[derive(TryFromBytes)]
3241 /// #[derive(TryFromBytes)]
3407 /// [`#[derive(FromZeros)]`][derive]; e.g.:
3411 /// #[derive(FromZeros)]
3418 /// #[derive(FromZeros)]
3427 /// #[derive(FromZeros, Immutable)]
3436 /// This derive performs a sophisticated, compile-time safety analysis to
3450 /// `#[derive(FromZeros)]` only permits [types which satisfy these
3451 /// requirements][derive-analysis].
3454 feature = "derive",
3455 doc = "[derive]: zerocopy_derive::FromZeros",
3456 doc = "[derive-analysis]: zerocopy_derive::FromZeros#analysis"
3459 not(feature = "derive"),
3460 …doc = concat!("[derive]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocopy/derive.…
3461 …doc = concat!("[derive-analysis]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocop…
3465 diagnostic::on_unimplemented(note = "Consider adding `#[derive(FromZeros)]` to `{Self}`")
3488 /// #[derive(FromZeros)]
3558 /// #[derive(FromZeros)]
3833 /// This derive analyzes, at compile time, whether the annotated type satisfies
3835 /// supertraits if it is sound to do so. This derive can be applied to structs,
3841 /// #[derive(FromBytes)]
3848 /// #[derive(FromBytes)]
3874 /// #[derive(FromBytes, Immutable)]
3887 /// *This section describes, roughly, the analysis performed by this derive to
3889 /// Unless you are modifying the implementation of this derive, or attempting to
3893 /// If a type has the following properties, then this derive can implement
3906 /// implementation details of this derive.
3910 /// Neither this derive, nor the [safety conditions] of `FromBytes`, requires
3934 #[cfg(any(feature = "derive", test))]
3935 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))]
3957 /// #[derive(FromZeros, Default)]
3975 /// [`#[derive(FromBytes)]`][derive]; e.g.:
3979 /// #[derive(FromBytes)]
3986 /// #[derive(FromBytes)]
4012 /// #[derive(FromBytes, Immutable)]
4021 /// This derive performs a sophisticated, compile-time safety analysis to
4036 /// `#[derive(FromBytes)]` only permits [types which satisfy these
4037 /// requirements][derive-analysis].
4040 feature = "derive",
4041 doc = "[derive]: zerocopy_derive::FromBytes",
4042 doc = "[derive-analysis]: zerocopy_derive::FromBytes#analysis"
4045 not(feature = "derive"),
4046 …doc = concat!("[derive]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocopy/derive.…
4047 …doc = concat!("[derive-analysis]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocop…
4051 diagnostic::on_unimplemented(note = "Consider adding `#[derive(FromBytes)]` to `{Self}`")
4086 /// #[derive(FromBytes, Immutable, KnownLayout)]
4102 /// #[derive(FromBytes, KnownLayout, Immutable)]
4111 /// #[derive(FromBytes, KnownLayout, Immutable)]
4195 /// #[derive(FromBytes, Immutable, KnownLayout)]
4213 /// #[derive(FromBytes, KnownLayout, Immutable)]
4222 /// #[derive(FromBytes, KnownLayout, Immutable)]
4303 /// #[derive(FromBytes, Immutable, KnownLayout)]
4321 /// #[derive(FromBytes, Immutable, KnownLayout)]
4395 /// #[derive(FromBytes, Immutable, IntoBytes, KnownLayout)]
4414 /// #[derive(FromBytes, IntoBytes, KnownLayout, Immutable)]
4485 /// #[derive(FromBytes, Immutable, IntoBytes, KnownLayout)]
4504 /// #[derive(FromBytes, IntoBytes, KnownLayout, Immutable)]
4574 /// #[derive(FromBytes, Immutable, IntoBytes, KnownLayout)]
4591 /// #[derive(FromBytes, IntoBytes, KnownLayout, Immutable)]
4646 /// # #[derive(Debug, PartialEq, Eq)]
4647 /// #[derive(FromBytes, Immutable)]
4675 /// #[derive(FromBytes, Immutable, KnownLayout)]
4743 /// # #[derive(Debug, PartialEq, Eq)]
4744 /// #[derive(FromBytes, Immutable)]
4774 /// #[derive(FromBytes, Immutable, KnownLayout)]
4837 /// # #[derive(Debug, PartialEq, Eq)]
4838 /// #[derive(FromBytes, Immutable)]
4868 /// #[derive(FromBytes, Immutable, KnownLayout)]
4931 /// # #[derive(Debug, PartialEq, Eq)]
4932 /// #[derive(KnownLayout, FromBytes, IntoBytes, Immutable)]
4963 /// #[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
5017 /// # #[derive(Debug, PartialEq, Eq)]
5018 /// #[derive(KnownLayout, FromBytes, IntoBytes, Immutable)]
5053 /// #[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
5102 /// # #[derive(Debug, PartialEq, Eq)]
5103 /// #[derive(FromBytes, IntoBytes, Immutable)]
5138 /// #[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
5178 /// #[derive(FromBytes)]
5235 /// #[derive(FromBytes)]
5293 /// #[derive(FromBytes)]
5345 /// #[derive(FromBytes)]
5508 /// This derive analyzes, at compile time, whether the annotated type satisfies
5510 /// sound to do so. This derive can be applied to structs and enums (see below
5515 /// #[derive(IntoBytes)]
5523 /// #[derive(IntoBytes)]
5537 /// On Rust toolchains prior to 1.78.0, due to the way that the custom derive
5544 /// 1 | #[derive(IntoBytes)]
5563 /// zerocopy does not support `#[derive(IntoBytes)]` on unions by default.
5566 /// future. You can opt-in to `#[derive(IntoBytes)]` support on unions by
5573 /// However, it is your responsibility to ensure that this derive is sound on
5589 /// *This section describes, roughly, the analysis performed by this derive to
5591 /// Unless you are modifying the implementation of this derive, or attempting to
5595 /// If a type has the following properties, then this derive can implement
5614 /// implementation details of this derive.
5617 #[cfg(any(feature = "derive", test))]
5618 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))]
5630 /// [`#[derive(IntoBytes)]`][derive]; e.g.:
5634 /// #[derive(IntoBytes)]
5642 /// #[derive(IntoBytes)]
5652 /// This derive performs a sophisticated, compile-time safety analysis to
5653 /// determine whether a type is `IntoBytes`. See the [derive
5654 /// documentation][derive] for guidance on how to interpret error messages
5655 /// produced by the derive's analysis.
5669 /// `#[derive(IntoBytes)]` only permits [types which satisfy these
5670 /// requirements][derive-analysis].
5673 feature = "derive",
5674 doc = "[derive]: zerocopy_derive::IntoBytes",
5675 doc = "[derive-analysis]: zerocopy_derive::IntoBytes#analysis"
5678 not(feature = "derive"),
5679 …doc = concat!("[derive]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocopy/derive.…
5680 …doc = concat!("[derive-analysis]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocop…
5684 diagnostic::on_unimplemented(note = "Consider adding `#[derive(IntoBytes)]` to `{Self}`")
5706 /// #[derive(IntoBytes, Immutable)]
5786 /// # #[derive(Eq, PartialEq, Debug)]
5787 /// #[derive(FromBytes, IntoBytes, Immutable)]
5864 /// #[derive(IntoBytes, Immutable)]
5950 /// #[derive(IntoBytes, Immutable)]
6038 /// #[derive(IntoBytes, Immutable)]
6144 /// #[derive(FromBytes, IntoBytes, Immutable, KnownLayout)]
6195 /// This derive analyzes, at compile time, whether the annotated type satisfies
6197 /// sound to do so. This derive can be applied to structs, enums, and unions;
6202 /// #[derive(Unaligned)]
6210 /// #[derive(Unaligned)]
6219 /// #[derive(Unaligned)]
6231 /// *This section describes, roughly, the analysis performed by this derive to
6233 /// Unless you are modifying the implementation of this derive, or attempting to
6237 /// If a type has the following properties, then this derive can implement
6252 #[cfg(any(feature = "derive", test))]
6253 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))]
6263 /// [`#[derive(Unaligned)]`][derive]; e.g.:
6267 /// #[derive(Unaligned)]
6275 /// #[derive(Unaligned)]
6284 /// #[derive(Unaligned)]
6294 /// This derive performs a sophisticated, compile-time safety analysis to
6309 /// `#[derive(Unaligned)]` only permits [types which satisfy these
6310 /// requirements][derive-analysis].
6313 feature = "derive",
6314 doc = "[derive]: zerocopy_derive::Unaligned",
6315 doc = "[derive-analysis]: zerocopy_derive::Unaligned#analysis"
6318 not(feature = "derive"),
6319 …doc = concat!("[derive]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocopy/derive.…
6320 …doc = concat!("[derive-analysis]: https://docs.rs/zerocopy/", env!("CARGO_PKG_VERSION"), "/zerocop…
6324 diagnostic::on_unimplemented(note = "Consider adding `#[derive(Unaligned)]` to `{Self}`")
6337 /// This derive can be applied to structs and enums implementing both
6342 /// #[derive(ByteEq, Immutable, IntoBytes)]
6350 /// #[derive(ByteEq, Immutable, IntoBytes)]
6360 /// The standard library's [`derive(Eq, PartialEq)`][derive@PartialEq] computes
6362 /// of [`PartialEq::eq`] emitted by `derive(ByteHash)` converts the entirety of
6365 #[cfg(any(feature = "derive", test))]
6366 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))]
6370 /// This derive can be applied to structs and enums implementing both
6375 /// #[derive(ByteHash, Immutable, IntoBytes)]
6383 /// #[derive(ByteHash, Immutable, IntoBytes)]
6393 /// The standard library's [`derive(Hash)`][derive@Hash] produces hashes by
6396 /// `derive(ByteHash)` convert the entirety of `self` to a byte slice and hashes
6403 #[cfg(any(feature = "derive", test))]
6404 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))]
6408 /// This derive can be applied to structs; e.g.:
6412 /// #[derive(ByteEq, Immutable, IntoBytes)]
6420 #[cfg(any(feature = "derive", test))]
6421 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))]
6479 #[derive(Debug, Eq, PartialEq, FromBytes, IntoBytes, Unaligned, Immutable)]
6536 #[cfg(feature = "derive")]
6541 // modes of `derive(KnownLayout)` for the following combination of in test_known_layout_derive()
6570 #[derive(KnownLayout)] in test_known_layout_derive()
6600 #[derive(KnownLayout)] in test_known_layout_derive()
6610 #[derive(KnownLayout)] in test_known_layout_derive()
6621 #[derive(KnownLayout)] in test_known_layout_derive()
6632 #[derive(KnownLayout)] in test_known_layout_derive()
6646 #[derive(KnownLayout)] in test_known_layout_derive()
6656 #[derive(KnownLayout)] in test_known_layout_derive()
6667 #[derive(KnownLayout)] in test_known_layout_derive()
6678 #[derive(KnownLayout)] in test_known_layout_derive()
6692 #[derive(KnownLayout)] in test_known_layout_derive()
6702 #[derive(KnownLayout)] in test_known_layout_derive()
6712 #[derive(KnownLayout)] in test_known_layout_derive()
6726 #[derive(KnownLayout)] in test_known_layout_derive()
6742 #[derive(KnownLayout)] in test_known_layout_derive()
6758 #[derive(KnownLayout)] in test_known_layout_derive()
6775 #[derive(KnownLayout)] in test_known_layout_derive()
6789 #[derive(KnownLayout)] in test_known_layout_derive()
6805 #[derive(KnownLayout)] in test_known_layout_derive()
6821 #[derive(KnownLayout)] in test_known_layout_derive()
6838 #[derive(KnownLayout)] in test_known_layout_derive()
6849 #[derive(KnownLayout)] in test_known_layout_derive()
6866 #[derive(KnownLayout)] in test_known_layout_derive()
6908 #[derive(KnownLayout)] in test_known_layout_derive()
6914 #[derive(KnownLayout)] in test_known_layout_derive()
6920 #[derive(KnownLayout)] in test_known_layout_derive()
6926 #[derive(KnownLayout)] in test_known_layout_derive()
6932 #[derive(KnownLayout)] in test_known_layout_derive()
7047 #[derive(FromBytes)] in test_read_io_with_padding_soundness()
7297 #[derive(Debug, Eq, PartialEq, FromBytes, IntoBytes, Immutable)] in test_to_methods()
7326 #[derive(FromBytes, IntoBytes, Immutable)] in test_array()
7351 #[derive(IntoBytes, FromBytes, Unaligned)] in test_transparent_packed_generic_struct()
7362 #[derive(IntoBytes, FromBytes, Unaligned)] in test_transparent_packed_generic_struct()