fn generate_byte_conversion_impls_unpacked(&self, config: &Config) -> TokenStream2 {
        let span = self.item_struct.span();
        let ident = &self.item_struct.ident;
        let size = self.generate_target_or_actual_bitfield_size(config);
        let next_divisible_by_8 = Self::next_divisible_by_8(&size);
        let repr = self.get_repr_or_bits(config);
        let repr_type = repr.into_quote();

        let from_bytes = match config.filled_enabled() {
            true => {
                quote_spanned!(span=>
                    /// Converts the given bytes directly into the bitfield struct.
                    ///
                    /// Expects Little Endian byte order.
                    #[inline(always)]
                    #[allow(clippy::identity_op)]
                    pub fn from_le_bytes(bytes: [u8; #next_divisible_by_8 / 8usize]) -> Self {
                        let value = #repr_type::from_le_bytes(bytes);
                        value.into()
                    }
                )
            }
            false => {
                quote_spanned!(span=>
                    /// Converts the given bytes directly into the bitfield struct.
                    ///
                    /// # Errors
                    ///
                    /// If the given bytes contain bits at positions that are undefined for `Self`.
                    #[inline]
                    #[allow(clippy::identity_op)]
                    pub fn from_le_bytes(
                        bytes: [u8; #next_divisible_by_8 / 8usize]
                    ) -> ::core::result::Result<Self, ::modular_bitfield::error::OutOfBounds> {
                        if bytes[(#next_divisible_by_8 / 8usize) - 1] >= (0x01 << (8 - (#next_divisible_by_8 - #size))) {
                            return ::core::result::Result::Err(::modular_bitfield::error::OutOfBounds)
                        }

                        let value = #repr_type::from_le_bytes(bytes);

                        ::core::result::Result::Ok(value.into())
                    }
                )
            }
        };

        quote_spanned!(span=>
            impl #ident {
                /// Returns the underlying bits.
                ///
                /// # Layout
                ///
                /// Returns a little endian based layout.
                /// The returned byte array is laid out in the same way as described
                /// [here](https://docs.rs/modular-bitfield/#generated-structure).
                #[inline(always)]
                #[allow(clippy::identity_op)]
                pub fn to_le_bytes(self) -> [u8; #next_divisible_by_8 / 8usize] {
                    let value: #repr_type = self.into();
                    value.to_le_bytes()
                }

                #from_bytes
            }
        )
    }
/// Generates routines to allow conversion from and to bytes for the `#[bitfield]` struct.
Generates routines to allow conversion from and to bytes for the `#[bitfield]` struct.
Generates routines to allow conversion from and to bytes for the ` # [ bitfield ] ` struct .
fn generate_byte_conversion_impls_unpacked(&self, config: &Config) -> TokenStream2 {
        let span = self.item_struct.span();
        let ident = &self.item_struct.ident;
        let size = self.generate_target_or_actual_bitfield_size(config);
        let next_divisible_by_8 = Self::next_divisible_by_8(&size);
        let repr = self.get_repr_or_bits(config);
        let repr_type = repr.into_quote();
        let from_bytes = match config.filled_enabled() {
            true => {
                quote_spanned!(span=>
                    /// Converts the given bytes directly into the bitfield struct.
                    ///
                    /// Expects Little Endian byte order.
                    #[inline(always)]
                    #[allow(clippy::identity_op)]
                    pub fn from_le_bytes(bytes: [u8; #next_divisible_by_8 / 8usize]) -> Self {
                        let value = #repr_type::from_le_bytes(bytes);
                        value.into()
                    }
                )
            }
            false => {
                quote_spanned!(span=>
                    /// Converts the given bytes directly into the bitfield struct.
                    ///
                    /// # Errors
                    ///
                    /// If the given bytes contain bits at positions that are undefined for `Self`.
                    #[inline]
                    #[allow(clippy::identity_op)]
                    pub fn from_le_bytes(
                        bytes: [u8; #next_divisible_by_8 / 8usize]
                    ) -> ::core::result::Result<Self, ::modular_bitfield::error::OutOfBounds> {
                        if bytes[(#next_divisible_by_8 / 8usize) - 1] >= (0x01 << (8 - (#next_divisible_by_8 - #size))) {
                            return ::core::result::Result::Err(::modular_bitfield::error::OutOfBounds)
                        }
                        let value = #repr_type::from_le_bytes(bytes);
                        ::core::result::Result::Ok(value.into())
                    }
                )
            }
        };
        quote_spanned!(span=>
            impl #ident {
                /// Returns the underlying bits.
                ///
                /// # Layout
                ///
                /// Returns a little endian based layout.
                /// The returned byte array is laid out in the same way as described
                /// [here](https://docs.rs/modular-bitfield/#generated-structure).
                #[inline(always)]
                #[allow(clippy::identity_op)]
                pub fn to_le_bytes(self) -> [u8; #next_divisible_by_8 / 8usize] {
                    let value: #repr_type = self.into();
                    value.to_le_bytes()
                }
                #from_bytes
            }
        )
    }
fn generate_byte_conversion_impls_unpacked ( & self , config : & Config ) -> TokenStream2 { let span = self . item_struct . span ( ) ; let ident = & self . item_struct . ident ; let size = self . generate_target_or_actual_bitfield_size ( config ) ; let next_divisible_by_8 = Self :: next_divisible_by_8 ( & size ) ; let repr = self . get_repr_or_bits ( config ) ; let repr_type = repr . into_quote ( ) ; let from_bytes = match config . filled_enabled ( ) { true => { quote_spanned ! ( span /// Converts the given bytes directly into the bitfield struct. /// Expects Little Endian byte order. [ inline ( always ) ] [ allow ( clippy identity_op ) ] pub fn from_le_bytes ( bytes [ u8 next_divisible_by_8 8usize ] ) Self { let value repr_type from_le_bytes ( bytes ) value into ( ) } ) } false => { quote_spanned ! ( span /// Converts the given bytes directly into the bitfield struct. /// # Errors /// If the given bytes contain bits at positions that are undefined for `Self`. [ inline ] [ allow ( clippy identity_op ) ] pub fn from_le_bytes ( bytes [ u8 next_divisible_by_8 8usize ] ) core result Result Self modular_bitfield error OutOfBounds { if bytes [ ( next_divisible_by_8 8usize ) 1 ] ( 0x01 ( 8 ( next_divisible_by_8 size ) ) ) { return core result Result Err ( modular_bitfield error OutOfBounds ) } let value repr_type from_le_bytes ( bytes ) core result Result Ok ( value into ( ) ) } ) } } ; quote_spanned ! ( span impl ident { /// Returns the underlying bits. /// # Layout /// Returns a little endian based layout. /// The returned byte array is laid out in the same way as described /// [here](https://docs.rs/modular-bitfield/#generated-structure). [ inline ( always ) ] [ allow ( clippy identity_op ) ] pub fn to_le_bytes ( self ) [ u8 next_divisible_by_8 8usize ] { let value repr_type self into ( ) value to_le_bytes ( ) } from_bytes } ) }
Generates routines to allow conversion from and to bytes for the `#[bitfield]` struct.
Generates routines to allow conversion from and to bytes for the ` # [ bitfield ] ` struct .
&self
config
&Config
&self
config
&Config