Skip to main content

asbytes/
lib.rs

1#![doc(html_logo_url = "https://raw.githubusercontent.com/Wandalen/wTools/master/asset/img/logo_v3_trans_square.png")]
2#![doc(
3  html_favicon_url = "https://raw.githubusercontent.com/Wandalen/wTools/alpha/asset/img/logo_v3_trans_square_icon_small_v2.ico"
4)]
5#![doc(html_root_url = "https://docs.rs/asbytes/latest/asbytes/")]
6#![ cfg_attr( doc, doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "readme.md" ) ) ) ]
7#![ cfg_attr( not( doc ), doc = "Byte conversion utilities" ) ]
8
9/// Namespace with dependencies.
10#[ cfg( feature = "enabled" ) ]
11pub mod dependency
12{
13  // Only include bytemuck if either as_bytes or into_bytes is enabled
14  #[ cfg(any(feature = "as_bytes", feature = "into_bytes")) ]
15  pub use ::bytemuck;
16}
17
18/// Define a private namespace for all its items.
19#[ cfg( feature = "enabled" ) ]
20mod private
21{
22}
23
24#[ cfg( feature = "as_bytes" ) ]
25mod as_bytes;
26#[ cfg( feature = "into_bytes" ) ]
27mod into_bytes;
28
29#[ cfg( feature = "enabled" ) ]
30#[ doc( inline ) ]
31#[ allow( unused_imports ) ]
32pub use own::*;
33
34/// Own namespace of the module.
35#[ cfg( feature = "enabled" ) ]
36#[ allow( unused_imports ) ]
37pub mod own
38{
39  use super::*;
40
41  #[ doc( inline ) ]
42  pub use orphan::*;
43
44  #[ doc( inline ) ]
45  #[ cfg( feature = "as_bytes" ) ]
46  pub use as_bytes::orphan::*;
47  #[ doc( inline ) ]
48  #[ cfg( feature = "into_bytes" ) ]
49  pub use into_bytes::orphan::*;
50
51  // Re-export bytemuck items only if a feature needing it is enabled
52  #[ cfg(any(feature = "as_bytes", feature = "into_bytes")) ]
53  #[ doc( inline ) ]
54  pub use bytemuck :: {
55  checked, offset_of, bytes_of, bytes_of_mut, cast, cast_mut, cast_ref, cast_slice, cast_slice_mut, fill_zeroes, from_bytes,
56  from_bytes_mut, pod_align_to, pod_align_to_mut, pod_read_unaligned, try_cast, try_cast_mut, try_cast_ref, try_cast_slice,
57  try_cast_slice_mut, try_from_bytes, try_from_bytes_mut, try_pod_read_unaligned, write_zeroes, CheckedBitPattern,
58  PodCastError, AnyBitPattern, Contiguous, NoUninit, Pod, PodInOption, TransparentWrapper, Zeroable, ZeroableInOption,
59 };
60
61  // Expose allocation submodule if into_bytes and extern_crate_alloc are enabled
62  #[ cfg(all(feature = "into_bytes", feature = "extern_crate_alloc")) ]
63  pub use bytemuck ::allocation;
64}
65
66/// Orphan namespace of the module.
67#[ cfg( feature = "enabled" ) ]
68#[ allow( unused_imports ) ]
69pub mod orphan 
70{
71  use super::*;
72
73  #[ doc( inline ) ]
74  pub use exposed :: *;
75}
76
77/// Exposed namespace of the module.
78#[ cfg( feature = "enabled" ) ]
79#[ allow( unused_imports ) ]
80pub mod exposed 
81{
82  use super::*;
83
84  #[ doc( inline ) ]
85  #[ cfg( feature = "as_bytes" ) ]
86  pub use as_bytes ::exposed :: *;
87  #[ doc( inline ) ]
88  #[ cfg( feature = "into_bytes" ) ]
89  pub use into_bytes ::exposed :: *;
90
91  #[ doc( inline ) ]
92  pub use prelude :: *;
93}
94
95/// Prelude to use essentials: `use my_module ::prelude :: *`.
96#[ cfg( feature = "enabled" ) ]
97#[ allow( unused_imports ) ]
98pub mod prelude 
99{
100  use super::*;
101  #[ doc( inline ) ]
102  #[ cfg( feature = "as_bytes" ) ]
103  pub use as_bytes ::prelude :: *;
104  #[ doc( inline ) ]
105  #[ cfg( feature = "into_bytes" ) ]
106  pub use into_bytes ::prelude :: *;
107}