rust/zerocopy/src/byteorder.rs
Source file repositories/reference/linux-study-clean/rust/zerocopy/src/byteorder.rs
File Facts
- System
- Linux kernel
- Corpus path
rust/zerocopy/src/byteorder.rs- Extension
.rs- Size
- 54742 bytes
- Lines
- 1565
- Domain
- Rust Kernel Layer
- Bucket
- Rust API Membrane
- Inferred role
- Rust Kernel Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
Rust-side wrappers and abstractions around kernel C APIs, ownership contracts, allocation, synchronization, and module integration.
- Rust-side wrappers and abstractions around kernel C APIs, ownership contracts, allocation, synchronization, and module integration.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function getfunction assert_eq_or_nanfunction assert_eq_or_nanfunction newfunction test_const_methodsfunction test_zerofunction test_max_valuefunction test_endianfunction test_ops_implsfunction test_debug_implfunction test_byteorder_traits_coverage
Annotated Snippet
pub fn set(&mut self, n: $native) {
*self = Self::new(n);
}
}
// The reasoning behind which traits to implement here is to only
// implement traits which won't cause inference issues. Notably,
// comparison traits like PartialEq and PartialOrd tend to cause
// inference issues.
impl<O: ByteOrder> From<$name<O>> for [u8; $bytes] {
#[inline(always)]
fn from(x: $name<O>) -> [u8; $bytes] {
x.0
}
}
impl<O: ByteOrder> From<[u8; $bytes]> for $name<O> {
#[inline(always)]
fn from(bytes: [u8; $bytes]) -> $name<O> {
$name(bytes, PhantomData)
}
}
impl<O: ByteOrder> From<$name<O>> for $native {
#[inline(always)]
fn from(x: $name<O>) -> $native {
x.get()
}
}
impl<O: ByteOrder> From<$native> for $name<O> {
#[inline(always)]
fn from(x: $native) -> $name<O> {
$name::new(x)
}
}
$(
impl<O: ByteOrder> From<$name<O>> for $larger_native {
#[inline(always)]
fn from(x: $name<O>) -> $larger_native {
x.get().into()
}
}
)*
$(
impl<O: ByteOrder> TryFrom<$larger_native_try> for $name<O> {
type Error = TryFromIntError;
#[inline(always)]
fn try_from(x: $larger_native_try) -> Result<$name<O>, TryFromIntError> {
$native::try_from(x).map($name::new)
}
}
)*
$(
impl<O: ByteOrder, P: ByteOrder> From<$name<O>> for $larger_byteorder<P> {
#[inline(always)]
fn from(x: $name<O>) -> $larger_byteorder<P> {
$larger_byteorder::new(x.get().into())
}
}
)*
$(
impl<O: ByteOrder, P: ByteOrder> TryFrom<$larger_byteorder_try<P>> for $name<O> {
type Error = TryFromIntError;
#[inline(always)]
fn try_from(x: $larger_byteorder_try<P>) -> Result<$name<O>, TryFromIntError> {
x.get().try_into().map($name::new)
}
}
)*
impl<O> AsRef<[u8; $bytes]> for $name<O> {
#[inline(always)]
fn as_ref(&self) -> &[u8; $bytes] {
&self.0
}
}
impl<O> AsMut<[u8; $bytes]> for $name<O> {
#[inline(always)]
fn as_mut(&mut self) -> &mut [u8; $bytes] {
&mut self.0
}
}
Annotation
- Detected declarations: `function get`, `function assert_eq_or_nan`, `function assert_eq_or_nan`, `function new`, `function test_const_methods`, `function test_zero`, `function test_max_value`, `function test_endian`, `function test_ops_impls`, `function test_debug_impl`.
- Atlas domain: Rust Kernel Layer / Rust API Membrane.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.