asbytes/
lib.rs

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