@@ -1713,8 +1713,8 @@ pub unsafe trait TryFromBytes {
1713
1713
/// use zerocopy::*;
1714
1714
/// # use zerocopy_derive::*;
1715
1715
///
1716
- /// #[derive(TryFromBytes, KnownLayout)]
1717
- /// #[repr(C)]
1716
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1717
+ /// #[repr(C, packed )]
1718
1718
/// struct ZSTy {
1719
1719
/// leading_sized: [u8; 2],
1720
1720
/// trailing_dst: [()],
@@ -1731,17 +1731,17 @@ pub unsafe trait TryFromBytes {
1731
1731
/// # use zerocopy_derive::*;
1732
1732
///
1733
1733
/// // The only valid value of this type is the byte `0xC0`
1734
- /// #[derive(TryFromBytes, KnownLayout)]
1734
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1735
1735
/// #[repr(u8)]
1736
1736
/// enum C0 { xC0 = 0xC0 }
1737
1737
///
1738
1738
/// // The only valid value of this type is the bytes `0xC0C0`.
1739
- /// #[derive(TryFromBytes, KnownLayout)]
1739
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1740
1740
/// #[repr(C)]
1741
1741
/// struct C0C0(C0, C0);
1742
1742
///
1743
- /// #[derive(TryFromBytes, KnownLayout)]
1744
- /// #[repr(C)]
1743
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1744
+ /// #[repr(C, packed )]
1745
1745
/// struct Packet {
1746
1746
/// magic_number: C0C0,
1747
1747
/// mug_size: u8,
@@ -1769,7 +1769,7 @@ pub unsafe trait TryFromBytes {
1769
1769
#[ inline]
1770
1770
fn try_mut_from_bytes ( bytes : & mut [ u8 ] ) -> Result < & mut Self , TryCastError < & mut [ u8 ] , Self > >
1771
1771
where
1772
- Self : KnownLayout ,
1772
+ Self : KnownLayout + IntoBytes ,
1773
1773
{
1774
1774
static_assert_dst_is_not_zst ! ( Self ) ;
1775
1775
match Ptr :: from_mut ( bytes) . try_cast_into_no_leftover :: < Self , BecauseExclusive > ( None ) {
@@ -1821,8 +1821,8 @@ pub unsafe trait TryFromBytes {
1821
1821
/// use zerocopy::*;
1822
1822
/// # use zerocopy_derive::*;
1823
1823
///
1824
- /// #[derive(TryFromBytes, KnownLayout)]
1825
- /// #[repr(C)]
1824
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1825
+ /// #[repr(C, packed )]
1826
1826
/// struct ZSTy {
1827
1827
/// leading_sized: [u8; 2],
1828
1828
/// trailing_dst: [()],
@@ -1839,17 +1839,17 @@ pub unsafe trait TryFromBytes {
1839
1839
/// # use zerocopy_derive::*;
1840
1840
///
1841
1841
/// // The only valid value of this type is the byte `0xC0`
1842
- /// #[derive(TryFromBytes, KnownLayout)]
1842
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1843
1843
/// #[repr(u8)]
1844
1844
/// enum C0 { xC0 = 0xC0 }
1845
1845
///
1846
1846
/// // The only valid value of this type is the bytes `0xC0C0`.
1847
- /// #[derive(TryFromBytes, KnownLayout)]
1847
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1848
1848
/// #[repr(C)]
1849
1849
/// struct C0C0(C0, C0);
1850
1850
///
1851
- /// #[derive(TryFromBytes, KnownLayout)]
1852
- /// #[repr(C)]
1851
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1852
+ /// #[repr(C, packed )]
1853
1853
/// struct Packet {
1854
1854
/// magic_number: C0C0,
1855
1855
/// mug_size: u8,
@@ -1882,7 +1882,7 @@ pub unsafe trait TryFromBytes {
1882
1882
source : & mut [ u8 ] ,
1883
1883
) -> Result < ( & mut Self , & mut [ u8 ] ) , TryCastError < & mut [ u8 ] , Self > >
1884
1884
where
1885
- Self : KnownLayout ,
1885
+ Self : KnownLayout + IntoBytes ,
1886
1886
{
1887
1887
static_assert_dst_is_not_zst ! ( Self ) ;
1888
1888
try_mut_from_prefix_suffix ( source, CastType :: Prefix , None )
@@ -1916,8 +1916,8 @@ pub unsafe trait TryFromBytes {
1916
1916
/// use zerocopy::*;
1917
1917
/// # use zerocopy_derive::*;
1918
1918
///
1919
- /// #[derive(TryFromBytes, KnownLayout)]
1920
- /// #[repr(C)]
1919
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1920
+ /// #[repr(C, packed )]
1921
1921
/// struct ZSTy {
1922
1922
/// leading_sized: u16,
1923
1923
/// trailing_dst: [()],
@@ -1934,17 +1934,17 @@ pub unsafe trait TryFromBytes {
1934
1934
/// # use zerocopy_derive::*;
1935
1935
///
1936
1936
/// // The only valid value of this type is the byte `0xC0`
1937
- /// #[derive(TryFromBytes, KnownLayout)]
1937
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1938
1938
/// #[repr(u8)]
1939
1939
/// enum C0 { xC0 = 0xC0 }
1940
1940
///
1941
1941
/// // The only valid value of this type is the bytes `0xC0C0`.
1942
- /// #[derive(TryFromBytes, KnownLayout)]
1942
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1943
1943
/// #[repr(C)]
1944
1944
/// struct C0C0(C0, C0);
1945
1945
///
1946
- /// #[derive(TryFromBytes, KnownLayout)]
1947
- /// #[repr(C)]
1946
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
1947
+ /// #[repr(C, packed )]
1948
1948
/// struct Packet {
1949
1949
/// magic_number: C0C0,
1950
1950
/// mug_size: u8,
@@ -1977,7 +1977,7 @@ pub unsafe trait TryFromBytes {
1977
1977
source : & mut [ u8 ] ,
1978
1978
) -> Result < ( & mut [ u8 ] , & mut Self ) , TryCastError < & mut [ u8 ] , Self > >
1979
1979
where
1980
- Self : KnownLayout ,
1980
+ Self : KnownLayout + IntoBytes ,
1981
1981
{
1982
1982
static_assert_dst_is_not_zst ! ( Self ) ;
1983
1983
try_mut_from_prefix_suffix ( source, CastType :: Suffix , None ) . map ( swap)
@@ -2286,17 +2286,17 @@ pub unsafe trait TryFromBytes {
2286
2286
/// # use zerocopy_derive::*;
2287
2287
///
2288
2288
/// // The only valid value of this type is the byte `0xC0`
2289
- /// #[derive(TryFromBytes, KnownLayout)]
2289
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2290
2290
/// #[repr(u8)]
2291
2291
/// enum C0 { xC0 = 0xC0 }
2292
2292
///
2293
2293
/// // The only valid value of this type is the bytes `0xC0C0`.
2294
- /// #[derive(TryFromBytes, KnownLayout)]
2294
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2295
2295
/// #[repr(C)]
2296
2296
/// struct C0C0(C0, C0);
2297
2297
///
2298
- /// #[derive(TryFromBytes, KnownLayout)]
2299
- /// #[repr(C)]
2298
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2299
+ /// #[repr(C, packed )]
2300
2300
/// struct Packet {
2301
2301
/// magic_number: C0C0,
2302
2302
/// mug_size: u8,
@@ -2330,8 +2330,8 @@ pub unsafe trait TryFromBytes {
2330
2330
/// use zerocopy::*;
2331
2331
/// # use zerocopy_derive::*;
2332
2332
///
2333
- /// #[derive(TryFromBytes, KnownLayout)]
2334
- /// #[repr(C)]
2333
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2334
+ /// #[repr(C, packed )]
2335
2335
/// struct ZSTy {
2336
2336
/// leading_sized: NonZeroU16,
2337
2337
/// trailing_dst: [()],
@@ -2351,7 +2351,7 @@ pub unsafe trait TryFromBytes {
2351
2351
count : usize ,
2352
2352
) -> Result < & mut Self , TryCastError < & mut [ u8 ] , Self > >
2353
2353
where
2354
- Self : KnownLayout < PointerMetadata = usize > ,
2354
+ Self : KnownLayout < PointerMetadata = usize > + IntoBytes ,
2355
2355
{
2356
2356
match Ptr :: from_mut ( source) . try_cast_into_no_leftover :: < Self , BecauseExclusive > ( Some ( count) )
2357
2357
{
@@ -2397,17 +2397,17 @@ pub unsafe trait TryFromBytes {
2397
2397
/// # use zerocopy_derive::*;
2398
2398
///
2399
2399
/// // The only valid value of this type is the byte `0xC0`
2400
- /// #[derive(TryFromBytes, KnownLayout)]
2400
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2401
2401
/// #[repr(u8)]
2402
2402
/// enum C0 { xC0 = 0xC0 }
2403
2403
///
2404
2404
/// // The only valid value of this type is the bytes `0xC0C0`.
2405
- /// #[derive(TryFromBytes, KnownLayout)]
2405
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2406
2406
/// #[repr(C)]
2407
2407
/// struct C0C0(C0, C0);
2408
2408
///
2409
- /// #[derive(TryFromBytes, KnownLayout)]
2410
- /// #[repr(C)]
2409
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2410
+ /// #[repr(C, packed )]
2411
2411
/// struct Packet {
2412
2412
/// magic_number: C0C0,
2413
2413
/// mug_size: u8,
@@ -2443,8 +2443,8 @@ pub unsafe trait TryFromBytes {
2443
2443
/// use zerocopy::*;
2444
2444
/// # use zerocopy_derive::*;
2445
2445
///
2446
- /// #[derive(TryFromBytes, KnownLayout)]
2447
- /// #[repr(C)]
2446
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2447
+ /// #[repr(C, packed )]
2448
2448
/// struct ZSTy {
2449
2449
/// leading_sized: NonZeroU16,
2450
2450
/// trailing_dst: [()],
@@ -2464,7 +2464,7 @@ pub unsafe trait TryFromBytes {
2464
2464
count : usize ,
2465
2465
) -> Result < ( & mut Self , & mut [ u8 ] ) , TryCastError < & mut [ u8 ] , Self > >
2466
2466
where
2467
- Self : KnownLayout < PointerMetadata = usize > ,
2467
+ Self : KnownLayout < PointerMetadata = usize > + IntoBytes ,
2468
2468
{
2469
2469
try_mut_from_prefix_suffix ( source, CastType :: Prefix , Some ( count) )
2470
2470
}
@@ -2492,17 +2492,17 @@ pub unsafe trait TryFromBytes {
2492
2492
/// # use zerocopy_derive::*;
2493
2493
///
2494
2494
/// // The only valid value of this type is the byte `0xC0`
2495
- /// #[derive(TryFromBytes, KnownLayout)]
2495
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2496
2496
/// #[repr(u8)]
2497
2497
/// enum C0 { xC0 = 0xC0 }
2498
2498
///
2499
2499
/// // The only valid value of this type is the bytes `0xC0C0`.
2500
- /// #[derive(TryFromBytes, KnownLayout)]
2500
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2501
2501
/// #[repr(C)]
2502
2502
/// struct C0C0(C0, C0);
2503
2503
///
2504
- /// #[derive(TryFromBytes, KnownLayout)]
2505
- /// #[repr(C)]
2504
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2505
+ /// #[repr(C, packed )]
2506
2506
/// struct Packet {
2507
2507
/// magic_number: C0C0,
2508
2508
/// mug_size: u8,
@@ -2538,8 +2538,8 @@ pub unsafe trait TryFromBytes {
2538
2538
/// use zerocopy::*;
2539
2539
/// # use zerocopy_derive::*;
2540
2540
///
2541
- /// #[derive(TryFromBytes, KnownLayout)]
2542
- /// #[repr(C)]
2541
+ /// #[derive(TryFromBytes, IntoBytes, KnownLayout)]
2542
+ /// #[repr(C, packed )]
2543
2543
/// struct ZSTy {
2544
2544
/// leading_sized: NonZeroU16,
2545
2545
/// trailing_dst: [()],
@@ -2559,7 +2559,7 @@ pub unsafe trait TryFromBytes {
2559
2559
count : usize ,
2560
2560
) -> Result < ( & mut [ u8 ] , & mut Self ) , TryCastError < & mut [ u8 ] , Self > >
2561
2561
where
2562
- Self : KnownLayout < PointerMetadata = usize > ,
2562
+ Self : KnownLayout < PointerMetadata = usize > + IntoBytes ,
2563
2563
{
2564
2564
try_mut_from_prefix_suffix ( source, CastType :: Suffix , Some ( count) ) . map ( swap)
2565
2565
}
@@ -2771,7 +2771,7 @@ fn try_ref_from_prefix_suffix<T: TryFromBytes + KnownLayout + Immutable + ?Sized
2771
2771
}
2772
2772
2773
2773
#[ inline( always) ]
2774
- fn try_mut_from_prefix_suffix < T : TryFromBytes + KnownLayout + ?Sized > (
2774
+ fn try_mut_from_prefix_suffix < T : IntoBytes + TryFromBytes + KnownLayout + ?Sized > (
2775
2775
candidate : & mut [ u8 ] ,
2776
2776
cast_type : CastType ,
2777
2777
meta : Option < T :: PointerMetadata > ,
0 commit comments