1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! `BorrowableSliceElement` marker trait for zero-copy slice borrow-decode.
//!
//! This module defines the `BorrowableSliceElement` unsafe marker trait that
//! enables `BorrowDecode<'de> for &'de [T]` for Pod-like primitive types.
use crateEndianness;
/// Marker trait for types that can be borrowed as a slice from an oxicode
/// input buffer, enabling zero-copy `BorrowDecode` of `&'de [Self]`.
///
/// # Safety
///
/// Implementors must guarantee all of the following:
///
/// 1. `Self` has a fixed, well-defined memory layout that does not change
/// between encoder and decoder.
/// 2. Every byte pattern of length `core::mem::size_of::<Self>()` is a
/// valid `Self` value (no validity invariants beyond raw bytes).
/// 3. Under `IntEncoding::Fixed` and a native-endian `Endianness`, the
/// on-disk encoding of `Self` is a verbatim copy of `Self`'s in-memory
/// bytes.
/// 4. `Self: Copy + Sized + 'static` (no interior references, no Drop).
///
/// Violating any invariant causes undefined behavior in the
/// `BorrowDecode<'de> for &'de [Self]` implementation, which uses
/// `core::slice::from_raw_parts` to reinterpret the input buffer.
///
/// # Built-in implementations
///
/// `oxicode` implements this trait for the following types:
/// `u16`, `u32`, `u64`, `i16`, `i32`, `i64`, `f32`, `f64`.
///
/// `u8`, `i8`, and `str` are handled by dedicated concrete `BorrowDecode`
/// implementations — they do **not** implement `BorrowableSliceElement`
/// to avoid conflicting trait implementations.
///
/// `u128`, `i128`, `usize`, `isize`, `bool`, `char`, and composite types
/// are intentionally excluded: 128-bit alignment cannot be guaranteed
/// after oxicode's 8-byte Fixint length prefix; platform-dependent or
/// restricted-bit-pattern types violate invariant 2.
pub unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe
unsafe