mod private
{
pub use bytemuck::
{
Pod,
};
pub trait IntoBytes
{
fn into_bytes( self ) -> Vec< u8 >;
}
impl< T : Pod > IntoBytes for ( T, )
{
#[ inline ]
fn into_bytes( self ) -> Vec< u8 >
{
bytemuck::bytes_of( &self.0 ).to_vec()
}
}
impl< T : Pod > IntoBytes for &T
{
#[ inline ]
fn into_bytes( self ) -> Vec< u8 >
{
bytemuck::bytes_of( self ).to_vec()
}
}
impl IntoBytes for String
{
#[ inline ]
fn into_bytes( self ) -> Vec< u8 >
{
self.into_bytes()
}
}
impl IntoBytes for &str
{
#[ inline ]
fn into_bytes( self ) -> Vec< u8 >
{
self.as_bytes().to_vec()
}
}
impl< T : Pod, const N : usize > IntoBytes for [ T ; N ]
{
#[ inline ]
fn into_bytes( self ) -> Vec< u8 >
{
bytemuck::cast_slice( &self ).to_vec()
}
}
impl< T : Pod > IntoBytes for Vec< T >
{
#[ inline ]
fn into_bytes( self ) -> Vec< u8 >
{
bytemuck::cast_slice( self.as_slice() ).to_vec()
}
}
impl< T : Pod > IntoBytes for Box< T >
{
#[ inline ]
fn into_bytes( self ) -> Vec< u8 >
{
bytemuck::bytes_of( &*self ).to_vec()
}
}
impl< T : Pod > IntoBytes for &[ T ]
{
#[ inline ]
fn into_bytes( self ) -> Vec< u8 >
{
bytemuck::cast_slice( self ).to_vec()
}
}
impl< T : Pod > IntoBytes for Box< [ T ] >
{
#[ inline ]
fn into_bytes( self ) -> Vec< u8 >
{
bytemuck::cast_slice( &*self ).to_vec()
}
}
impl< T : Pod > IntoBytes for std::collections::VecDeque< T >
{
#[ inline ]
fn into_bytes( self ) -> Vec< u8 >
{
let mut bytes = Vec::with_capacity( self.len() * std::mem::size_of::< T >() );
for element in self
{
bytes.extend_from_slice( bytemuck::bytes_of( &element ) );
}
bytes
}
}
impl IntoBytes for std::ffi::CString
{
#[ inline ]
fn into_bytes( self ) -> Vec< u8 >
{
self.into_bytes()
}
}
}
#[ doc( inline ) ]
#[ allow( unused_imports ) ]
pub use own::*;
#[ allow( unused_imports ) ]
pub mod own
{
use super::*;
#[ doc( inline ) ]
pub use orphan::*;
}
#[ doc( inline ) ]
#[ allow( unused_imports ) ]
pub use own::*;
#[ allow( unused_imports ) ]
pub mod orphan
{
use super::*;
#[ doc( inline ) ]
pub use exposed::*;
}
#[ allow( unused_imports ) ]
pub mod exposed
{
use super::*;
#[ doc( inline ) ]
pub use prelude::*;
}
#[ allow( unused_imports ) ]
pub mod prelude
{
use super::*;
pub use private::IntoBytes;
}