Coverage Report

Created: 2026-04-12 07:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/lebe-0.5.3/src/lib.rs
Line
Count
Source
1
#![warn(
2
    missing_docs, unused,
3
    trivial_numeric_casts,
4
    future_incompatible,
5
    rust_2018_compatibility,
6
    rust_2018_idioms,
7
    clippy::all
8
)]
9
10
#![doc(html_root_url = "https://docs.rs/lebe/0.5.0")]
11
12
//! Dead simple endianness conversions.
13
//! The following operations are implemented on
14
//! `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`, `u128`, `i128`, `f32`, `f64`:
15
//!
16
//!
17
//! ### Read Numbers
18
//! ```rust
19
//! use lebe::prelude::*;
20
//! let mut reader: &[u8] = &[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
21
//!
22
//! let number : u64 = reader.read_from_little_endian()?;
23
//! let number = u64::read_from_big_endian(&mut reader)?;
24
//! # Ok::<(), std::io::Error>(())
25
//! ```
26
//!
27
//! ### Read Slices
28
//! ```rust
29
//! use std::io::Read;
30
//! use lebe::prelude::*;
31
//! let mut reader: &[u8] = &[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
32
//!
33
//! let mut numbers: &mut [u64] = &mut [0, 0];
34
//! reader.read_from_little_endian_into(numbers)?;
35
//! # Ok::<(), std::io::Error>(())
36
//! ```
37
//!
38
//! ### Write Numbers
39
//! ```rust
40
//! use std::io::Read;
41
//! use lebe::prelude::*;
42
//! let mut writer: Vec<u8> = Vec::new();
43
//!
44
//! let number: u64 = 1237691;
45
//! writer.write_as_big_endian(&number)?;
46
//! # Ok::<(), std::io::Error>(())
47
//! ```
48
//!
49
//! ### Write Slices
50
//! ```rust
51
//! use std::io::Write;
52
//! use lebe::prelude::*;
53
//! let mut writer: Vec<u8> = Vec::new();
54
//!
55
//! let numbers: &[u64] = &[1_u64, 234545_u64];
56
//! writer.write_as_little_endian(numbers)?;
57
//! # Ok::<(), std::io::Error>(())
58
//! ```
59
//!
60
61
62
/// Exports some of the most common types.
63
pub mod prelude {
64
    pub use super::Endian;
65
    pub use super::io::{ WriteEndian, ReadEndian, ReadPrimitive };
66
}
67
68
/// Represents values that can swap their bytes to reverse their endianness.
69
///
70
/// Supports converting values in-place using [`swap_bytes`] or [`convert_current_to_little_endian`]:
71
/// Supports converting while transferring ownership using
72
/// [`from_little_endian_into_current`] or [`from_current_into_little_endian`].
73
///
74
///
75
/// For the types `u8`, `i8`, `&[u8]` and `&[i8]`, this trait will never transform any data,
76
/// as they are just implemented for completeness.
77
pub trait Endian {
78
79
    /// Swaps all bytes in this value, inverting its endianness.
80
    fn swap_bytes(&mut self);
81
82
    /// On a little endian machine, this does nothing.
83
    /// On a big endian machine, the bytes of this value are reversed.
84
206M
    #[inline] fn convert_current_to_little_endian(&mut self) {
85
        #[cfg(target_endian = "big")] {
86
            self.swap_bytes();
87
        }
88
206M
    }
<i32 as lebe::Endian>::convert_current_to_little_endian
Line
Count
Source
84
3.21M
    #[inline] fn convert_current_to_little_endian(&mut self) {
85
        #[cfg(target_endian = "big")] {
86
            self.swap_bytes();
87
        }
88
3.21M
    }
<u32 as lebe::Endian>::convert_current_to_little_endian
Line
Count
Source
84
243
    #[inline] fn convert_current_to_little_endian(&mut self) {
85
        #[cfg(target_endian = "big")] {
86
            self.swap_bytes();
87
        }
88
243
    }
<u16 as lebe::Endian>::convert_current_to_little_endian
Line
Count
Source
84
2.17M
    #[inline] fn convert_current_to_little_endian(&mut self) {
85
        #[cfg(target_endian = "big")] {
86
            self.swap_bytes();
87
        }
88
2.17M
    }
Unexecuted instantiation: <_ as lebe::Endian>::convert_current_to_little_endian
Unexecuted instantiation: <f64 as lebe::Endian>::convert_current_to_little_endian
Unexecuted instantiation: <f32 as lebe::Endian>::convert_current_to_little_endian
Unexecuted instantiation: <u8 as lebe::Endian>::convert_current_to_little_endian
Unexecuted instantiation: <u64 as lebe::Endian>::convert_current_to_little_endian
Unexecuted instantiation: <f64 as lebe::Endian>::convert_current_to_little_endian
<f32 as lebe::Endian>::convert_current_to_little_endian
Line
Count
Source
84
200M
    #[inline] fn convert_current_to_little_endian(&mut self) {
85
        #[cfg(target_endian = "big")] {
86
            self.swap_bytes();
87
        }
88
200M
    }
<u8 as lebe::Endian>::convert_current_to_little_endian
Line
Count
Source
84
2.83k
    #[inline] fn convert_current_to_little_endian(&mut self) {
85
        #[cfg(target_endian = "big")] {
86
            self.swap_bytes();
87
        }
88
2.83k
    }
Unexecuted instantiation: <u64 as lebe::Endian>::convert_current_to_little_endian
89
90
    /// On a big endian machine, this does nothing.
91
    /// On a little endian machine, the bytes of this value are reversed.
92
0
    #[inline] fn convert_current_to_big_endian(&mut self) {
93
0
        #[cfg(target_endian = "little")] {
94
0
            self.swap_bytes();
95
0
        }
96
0
    }
97
98
    /// On a little endian machine, this does nothing.
99
    /// On a big endian machine, the bytes of this value are reversed.
100
120M
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
120M
    }
<[i8] as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
190k
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
190k
    }
<[u64] as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
16.6k
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
16.6k
    }
<f64 as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
3.07k
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
3.07k
    }
Unexecuted instantiation: <u64 as lebe::Endian>::convert_little_endian_to_current
<[f32] as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
58.0M
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
58.0M
    }
<[u8] as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
2.53M
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
2.53M
    }
<[u32] as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
67.4k
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
67.4k
    }
<[u16] as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
173k
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
173k
    }
<f32 as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
363k
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
363k
    }
<u8 as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
50.1M
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
50.1M
    }
<i32 as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
6.54M
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
6.54M
    }
<u32 as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
141k
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
141k
    }
<u16 as lebe::Endian>::convert_little_endian_to_current
Line
Count
Source
100
2.17M
    #[inline] fn convert_little_endian_to_current(&mut self) {
101
        #[cfg(target_endian = "big")] {
102
            self.swap_bytes();
103
        }
104
2.17M
    }
Unexecuted instantiation: <_ as lebe::Endian>::convert_little_endian_to_current
105
106
    /// On a big endian machine, this does nothing.
107
    /// On a little endian machine, the bytes of this value are reversed.
108
0
    #[inline] fn convert_big_endian_to_current(&mut self) {
109
0
        #[cfg(target_endian = "little")] {
110
0
            self.swap_bytes();
111
0
        }
112
0
    }
113
114
    /// On a little endian machine, this does nothing.
115
    /// On a big endian machine, the bytes of this value are reversed.
116
206M
    #[inline] fn from_current_into_little_endian(mut self) -> Self where Self: Sized {
117
206M
        self.convert_current_to_little_endian();
118
206M
        self
119
206M
    }
<i32 as lebe::Endian>::from_current_into_little_endian
Line
Count
Source
116
3.21M
    #[inline] fn from_current_into_little_endian(mut self) -> Self where Self: Sized {
117
3.21M
        self.convert_current_to_little_endian();
118
3.21M
        self
119
3.21M
    }
<u32 as lebe::Endian>::from_current_into_little_endian
Line
Count
Source
116
243
    #[inline] fn from_current_into_little_endian(mut self) -> Self where Self: Sized {
117
243
        self.convert_current_to_little_endian();
118
243
        self
119
243
    }
<u16 as lebe::Endian>::from_current_into_little_endian
Line
Count
Source
116
2.17M
    #[inline] fn from_current_into_little_endian(mut self) -> Self where Self: Sized {
117
2.17M
        self.convert_current_to_little_endian();
118
2.17M
        self
119
2.17M
    }
Unexecuted instantiation: <_ as lebe::Endian>::from_current_into_little_endian
Unexecuted instantiation: <f64 as lebe::Endian>::from_current_into_little_endian
Unexecuted instantiation: <f32 as lebe::Endian>::from_current_into_little_endian
Unexecuted instantiation: <u8 as lebe::Endian>::from_current_into_little_endian
Unexecuted instantiation: <u64 as lebe::Endian>::from_current_into_little_endian
Unexecuted instantiation: <f64 as lebe::Endian>::from_current_into_little_endian
<f32 as lebe::Endian>::from_current_into_little_endian
Line
Count
Source
116
200M
    #[inline] fn from_current_into_little_endian(mut self) -> Self where Self: Sized {
117
200M
        self.convert_current_to_little_endian();
118
200M
        self
119
200M
    }
<u8 as lebe::Endian>::from_current_into_little_endian
Line
Count
Source
116
2.83k
    #[inline] fn from_current_into_little_endian(mut self) -> Self where Self: Sized {
117
2.83k
        self.convert_current_to_little_endian();
118
2.83k
        self
119
2.83k
    }
Unexecuted instantiation: <u64 as lebe::Endian>::from_current_into_little_endian
120
121
    /// On a big endian machine, this does nothing.
122
    /// On a little endian machine, the bytes of this value are reversed.
123
0
    #[inline] fn from_current_into_big_endian(mut self) -> Self where Self: Sized {
124
0
        self.convert_current_to_big_endian();
125
0
        self
126
0
    }
127
128
    /// On a little endian machine, this does nothing.
129
    /// On a big endian machine, the bytes of this value are reversed.
130
0
    #[inline] fn from_little_endian_into_current(mut self) -> Self where Self: Sized {
131
0
        self.convert_little_endian_to_current();
132
0
        self
133
0
    }
134
135
    /// On a big endian machine, this does nothing.
136
    /// On a little endian machine, the bytes of this value are reversed.
137
0
    #[inline] fn from_big_endian_into_current(mut self) -> Self where Self: Sized {
138
0
        self.convert_big_endian_to_current();
139
0
        self
140
0
    }
141
}
142
143
144
// call a macro for each argument
145
macro_rules! call_single_arg_macro_for_each {
146
    ($macro: ident, $( $arguments: ident ),* ) => {
147
        $( $macro! { $arguments }  )*
148
    };
149
}
150
151
// implement this interface for primitive signed and unsigned integers
152
macro_rules! implement_simple_primitive_endian {
153
    ($type: ident) => {
154
        impl Endian for $type {
155
0
            fn swap_bytes(&mut self) {
156
0
                *self = $type::swap_bytes(*self);
157
0
            }
Unexecuted instantiation: <u16 as lebe::Endian>::swap_bytes
Unexecuted instantiation: <u32 as lebe::Endian>::swap_bytes
Unexecuted instantiation: <u64 as lebe::Endian>::swap_bytes
Unexecuted instantiation: <u128 as lebe::Endian>::swap_bytes
Unexecuted instantiation: <i16 as lebe::Endian>::swap_bytes
Unexecuted instantiation: <i32 as lebe::Endian>::swap_bytes
Unexecuted instantiation: <i64 as lebe::Endian>::swap_bytes
Unexecuted instantiation: <i128 as lebe::Endian>::swap_bytes
158
        }
159
    };
160
}
161
162
163
call_single_arg_macro_for_each! {
164
    implement_simple_primitive_endian,
165
    u16, u32, u64, u128, i16, i32, i64, i128
166
}
167
168
// no-op implementations
169
0
impl Endian for u8 { fn swap_bytes(&mut self) {} }
170
0
impl Endian for i8 { fn swap_bytes(&mut self) {} }
171
0
impl Endian for [u8] { fn swap_bytes(&mut self) {} }
172
0
impl Endian for [i8] { fn swap_bytes(&mut self) {} }
173
174
// implement this interface for primitive floats, because they do not have a `swap_bytes()` in `std`
175
macro_rules! implement_float_primitive_by_bits {
176
    ($type: ident) => {
177
        impl Endian for $type {
178
0
            fn swap_bytes(&mut self) {
179
0
                *self = Self::from_bits(self.to_bits().swap_bytes());
180
0
            }
Unexecuted instantiation: <f32 as lebe::Endian>::swap_bytes
Unexecuted instantiation: <f64 as lebe::Endian>::swap_bytes
181
        }
182
    };
183
}
184
185
186
implement_float_primitive_by_bits!(f32);
187
implement_float_primitive_by_bits!(f64);
188
189
macro_rules! implement_slice_by_element {
190
    ($type: ident) => {
191
        impl Endian for [$type] {
192
0
            fn swap_bytes(&mut self) {
193
0
                for number in self.iter_mut() { // TODO SIMD?
194
0
                    number.swap_bytes();
195
0
                }
196
0
            }
Unexecuted instantiation: <[u16] as lebe::Endian>::swap_bytes
Unexecuted instantiation: <[u32] as lebe::Endian>::swap_bytes
Unexecuted instantiation: <[u64] as lebe::Endian>::swap_bytes
Unexecuted instantiation: <[u128] as lebe::Endian>::swap_bytes
Unexecuted instantiation: <[i16] as lebe::Endian>::swap_bytes
Unexecuted instantiation: <[i32] as lebe::Endian>::swap_bytes
Unexecuted instantiation: <[i64] as lebe::Endian>::swap_bytes
Unexecuted instantiation: <[i128] as lebe::Endian>::swap_bytes
Unexecuted instantiation: <[f64] as lebe::Endian>::swap_bytes
Unexecuted instantiation: <[f32] as lebe::Endian>::swap_bytes
197
        }
198
    };
199
}
200
201
call_single_arg_macro_for_each! {
202
    implement_slice_by_element,
203
    u16, u32, u64, u128,
204
    i16, i32, i64, i128,
205
    f64, f32
206
}
207
208
/// Easily write primitives and slices of primitives to
209
/// binary `std::io::Write` streams and easily read from binary `std::io::Read` streams.
210
///
211
/// Also contains the unsafe `bytes` module for reinterpreting values as byte slices and vice versa.
212
pub mod io {
213
    use super::Endian;
214
    use std::io::{Read, Write, Result};
215
216
    /// Reinterpret values as byte slices and byte slices as values unsafely.
217
    pub mod bytes {
218
        use std::io::{Read, Write, Result};
219
220
        /// View this slice of values as a slice of bytes.
221
        #[inline]
222
1.33M
        pub unsafe fn slice_as_bytes<T>(value: &[T]) -> &[u8] {
223
1.33M
            std::slice::from_raw_parts(
224
1.33M
                value.as_ptr() as *const u8,
225
1.33M
                value.len() * std::mem::size_of::<T>()
226
1.33M
            )
227
1.33M
        }
Unexecuted instantiation: lebe::io::bytes::slice_as_bytes::<f32>
lebe::io::bytes::slice_as_bytes::<u8>
Line
Count
Source
222
646k
        pub unsafe fn slice_as_bytes<T>(value: &[T]) -> &[u8] {
223
646k
            std::slice::from_raw_parts(
224
646k
                value.as_ptr() as *const u8,
225
646k
                value.len() * std::mem::size_of::<T>()
226
646k
            )
227
646k
        }
Unexecuted instantiation: lebe::io::bytes::slice_as_bytes::<u32>
lebe::io::bytes::slice_as_bytes::<u16>
Line
Count
Source
222
684k
        pub unsafe fn slice_as_bytes<T>(value: &[T]) -> &[u8] {
223
684k
            std::slice::from_raw_parts(
224
684k
                value.as_ptr() as *const u8,
225
684k
                value.len() * std::mem::size_of::<T>()
226
684k
            )
227
684k
        }
Unexecuted instantiation: lebe::io::bytes::slice_as_bytes::<_>
Unexecuted instantiation: lebe::io::bytes::slice_as_bytes::<i8>
Unexecuted instantiation: lebe::io::bytes::slice_as_bytes::<u64>
lebe::io::bytes::slice_as_bytes::<i8>
Line
Count
Source
222
324
        pub unsafe fn slice_as_bytes<T>(value: &[T]) -> &[u8] {
223
324
            std::slice::from_raw_parts(
224
324
                value.as_ptr() as *const u8,
225
324
                value.len() * std::mem::size_of::<T>()
226
324
            )
227
324
        }
lebe::io::bytes::slice_as_bytes::<u64>
Line
Count
Source
222
81
        pub unsafe fn slice_as_bytes<T>(value: &[T]) -> &[u8] {
223
81
            std::slice::from_raw_parts(
224
81
                value.as_ptr() as *const u8,
225
81
                value.len() * std::mem::size_of::<T>()
226
81
            )
227
81
        }
228
229
        /// View this slice of values as a mutable slice of bytes.
230
        #[inline]
231
61.0M
        pub unsafe fn slice_as_bytes_mut<T>(value: &mut [T]) -> &mut [u8] {
232
61.0M
            std::slice::from_raw_parts_mut(
233
61.0M
                value.as_mut_ptr() as *mut u8,
234
61.0M
                value.len() * std::mem::size_of::<T>()
235
61.0M
            )
236
61.0M
        }
lebe::io::bytes::slice_as_bytes_mut::<i8>
Line
Count
Source
231
190k
        pub unsafe fn slice_as_bytes_mut<T>(value: &mut [T]) -> &mut [u8] {
232
190k
            std::slice::from_raw_parts_mut(
233
190k
                value.as_mut_ptr() as *mut u8,
234
190k
                value.len() * std::mem::size_of::<T>()
235
190k
            )
236
190k
        }
lebe::io::bytes::slice_as_bytes_mut::<u64>
Line
Count
Source
231
16.8k
        pub unsafe fn slice_as_bytes_mut<T>(value: &mut [T]) -> &mut [u8] {
232
16.8k
            std::slice::from_raw_parts_mut(
233
16.8k
                value.as_mut_ptr() as *mut u8,
234
16.8k
                value.len() * std::mem::size_of::<T>()
235
16.8k
            )
236
16.8k
        }
lebe::io::bytes::slice_as_bytes_mut::<f32>
Line
Count
Source
231
58.0M
        pub unsafe fn slice_as_bytes_mut<T>(value: &mut [T]) -> &mut [u8] {
232
58.0M
            std::slice::from_raw_parts_mut(
233
58.0M
                value.as_mut_ptr() as *mut u8,
234
58.0M
                value.len() * std::mem::size_of::<T>()
235
58.0M
            )
236
58.0M
        }
lebe::io::bytes::slice_as_bytes_mut::<u8>
Line
Count
Source
231
2.53M
        pub unsafe fn slice_as_bytes_mut<T>(value: &mut [T]) -> &mut [u8] {
232
2.53M
            std::slice::from_raw_parts_mut(
233
2.53M
                value.as_mut_ptr() as *mut u8,
234
2.53M
                value.len() * std::mem::size_of::<T>()
235
2.53M
            )
236
2.53M
        }
lebe::io::bytes::slice_as_bytes_mut::<u32>
Line
Count
Source
231
67.4k
        pub unsafe fn slice_as_bytes_mut<T>(value: &mut [T]) -> &mut [u8] {
232
67.4k
            std::slice::from_raw_parts_mut(
233
67.4k
                value.as_mut_ptr() as *mut u8,
234
67.4k
                value.len() * std::mem::size_of::<T>()
235
67.4k
            )
236
67.4k
        }
lebe::io::bytes::slice_as_bytes_mut::<u16>
Line
Count
Source
231
173k
        pub unsafe fn slice_as_bytes_mut<T>(value: &mut [T]) -> &mut [u8] {
232
173k
            std::slice::from_raw_parts_mut(
233
173k
                value.as_mut_ptr() as *mut u8,
234
173k
                value.len() * std::mem::size_of::<T>()
235
173k
            )
236
173k
        }
Unexecuted instantiation: lebe::io::bytes::slice_as_bytes_mut::<_>
237
238
        /// View this reference as a slice of bytes.
239
        #[inline]
240
206M
        pub unsafe fn value_as_bytes<T: Sized>(value: &T) -> &[u8] {
241
206M
            std::slice::from_raw_parts(
242
206M
                value as *const T as *const u8,
243
206M
                std::mem::size_of::<T>()
244
206M
            )
245
206M
        }
lebe::io::bytes::value_as_bytes::<i32>
Line
Count
Source
240
3.21M
        pub unsafe fn value_as_bytes<T: Sized>(value: &T) -> &[u8] {
241
3.21M
            std::slice::from_raw_parts(
242
3.21M
                value as *const T as *const u8,
243
3.21M
                std::mem::size_of::<T>()
244
3.21M
            )
245
3.21M
        }
lebe::io::bytes::value_as_bytes::<u32>
Line
Count
Source
240
243
        pub unsafe fn value_as_bytes<T: Sized>(value: &T) -> &[u8] {
241
243
            std::slice::from_raw_parts(
242
243
                value as *const T as *const u8,
243
243
                std::mem::size_of::<T>()
244
243
            )
245
243
        }
lebe::io::bytes::value_as_bytes::<u16>
Line
Count
Source
240
2.17M
        pub unsafe fn value_as_bytes<T: Sized>(value: &T) -> &[u8] {
241
2.17M
            std::slice::from_raw_parts(
242
2.17M
                value as *const T as *const u8,
243
2.17M
                std::mem::size_of::<T>()
244
2.17M
            )
245
2.17M
        }
Unexecuted instantiation: lebe::io::bytes::value_as_bytes::<_>
Unexecuted instantiation: lebe::io::bytes::value_as_bytes::<f64>
Unexecuted instantiation: lebe::io::bytes::value_as_bytes::<f32>
Unexecuted instantiation: lebe::io::bytes::value_as_bytes::<u8>
Unexecuted instantiation: lebe::io::bytes::value_as_bytes::<u64>
Unexecuted instantiation: lebe::io::bytes::value_as_bytes::<f64>
lebe::io::bytes::value_as_bytes::<f32>
Line
Count
Source
240
200M
        pub unsafe fn value_as_bytes<T: Sized>(value: &T) -> &[u8] {
241
200M
            std::slice::from_raw_parts(
242
200M
                value as *const T as *const u8,
243
200M
                std::mem::size_of::<T>()
244
200M
            )
245
200M
        }
lebe::io::bytes::value_as_bytes::<u8>
Line
Count
Source
240
2.83k
        pub unsafe fn value_as_bytes<T: Sized>(value: &T) -> &[u8] {
241
2.83k
            std::slice::from_raw_parts(
242
2.83k
                value as *const T as *const u8,
243
2.83k
                std::mem::size_of::<T>()
244
2.83k
            )
245
2.83k
        }
Unexecuted instantiation: lebe::io::bytes::value_as_bytes::<u64>
246
247
        /// View this reference as a mutable slice of bytes.
248
        #[inline]
249
59.3M
        pub unsafe fn value_as_bytes_mut<T: Sized>(value: &mut T) ->&mut [u8] {
250
59.3M
            std::slice::from_raw_parts_mut(
251
59.3M
                value as *mut T as *mut u8,
252
59.3M
                std::mem::size_of::<T>()
253
59.3M
            )
254
59.3M
        }
lebe::io::bytes::value_as_bytes_mut::<f64>
Line
Count
Source
249
3.07k
        pub unsafe fn value_as_bytes_mut<T: Sized>(value: &mut T) ->&mut [u8] {
250
3.07k
            std::slice::from_raw_parts_mut(
251
3.07k
                value as *mut T as *mut u8,
252
3.07k
                std::mem::size_of::<T>()
253
3.07k
            )
254
3.07k
        }
Unexecuted instantiation: lebe::io::bytes::value_as_bytes_mut::<u64>
lebe::io::bytes::value_as_bytes_mut::<f32>
Line
Count
Source
249
363k
        pub unsafe fn value_as_bytes_mut<T: Sized>(value: &mut T) ->&mut [u8] {
250
363k
            std::slice::from_raw_parts_mut(
251
363k
                value as *mut T as *mut u8,
252
363k
                std::mem::size_of::<T>()
253
363k
            )
254
363k
        }
lebe::io::bytes::value_as_bytes_mut::<u8>
Line
Count
Source
249
50.1M
        pub unsafe fn value_as_bytes_mut<T: Sized>(value: &mut T) ->&mut [u8] {
250
50.1M
            std::slice::from_raw_parts_mut(
251
50.1M
                value as *mut T as *mut u8,
252
50.1M
                std::mem::size_of::<T>()
253
50.1M
            )
254
50.1M
        }
lebe::io::bytes::value_as_bytes_mut::<i32>
Line
Count
Source
249
6.54M
        pub unsafe fn value_as_bytes_mut<T: Sized>(value: &mut T) ->&mut [u8] {
250
6.54M
            std::slice::from_raw_parts_mut(
251
6.54M
                value as *mut T as *mut u8,
252
6.54M
                std::mem::size_of::<T>()
253
6.54M
            )
254
6.54M
        }
lebe::io::bytes::value_as_bytes_mut::<u32>
Line
Count
Source
249
141k
        pub unsafe fn value_as_bytes_mut<T: Sized>(value: &mut T) ->&mut [u8] {
250
141k
            std::slice::from_raw_parts_mut(
251
141k
                value as *mut T as *mut u8,
252
141k
                std::mem::size_of::<T>()
253
141k
            )
254
141k
        }
lebe::io::bytes::value_as_bytes_mut::<u16>
Line
Count
Source
249
2.17M
        pub unsafe fn value_as_bytes_mut<T: Sized>(value: &mut T) ->&mut [u8] {
250
2.17M
            std::slice::from_raw_parts_mut(
251
2.17M
                value as *mut T as *mut u8,
252
2.17M
                std::mem::size_of::<T>()
253
2.17M
            )
254
2.17M
        }
Unexecuted instantiation: lebe::io::bytes::value_as_bytes_mut::<_>
255
256
        /// View this slice as a mutable slice of bytes and write it.
257
        #[inline]
258
1.33M
        pub unsafe fn write_slice<T>(write: &mut impl Write, value: &[T]) -> Result<()> {
259
1.33M
            write.write_all(slice_as_bytes(value))
260
1.33M
        }
Unexecuted instantiation: lebe::io::bytes::write_slice::<f32, std::io::cursor::Cursor<&mut [u8]>>
lebe::io::bytes::write_slice::<u8, alloc::vec::Vec<u8>>
Line
Count
Source
258
284
        pub unsafe fn write_slice<T>(write: &mut impl Write, value: &[T]) -> Result<()> {
259
284
            write.write_all(slice_as_bytes(value))
260
284
        }
Unexecuted instantiation: lebe::io::bytes::write_slice::<u32, std::io::cursor::Cursor<alloc::vec::Vec<u8>>>
Unexecuted instantiation: lebe::io::bytes::write_slice::<u32, std::io::cursor::Cursor<&mut [u8]>>
Unexecuted instantiation: lebe::io::bytes::write_slice::<u16, alloc::vec::Vec<u8>>
Unexecuted instantiation: lebe::io::bytes::write_slice::<u16, std::io::cursor::Cursor<&mut [u8]>>
lebe::io::bytes::write_slice::<u16, &mut [u8]>
Line
Count
Source
258
684k
        pub unsafe fn write_slice<T>(write: &mut impl Write, value: &[T]) -> Result<()> {
259
684k
            write.write_all(slice_as_bytes(value))
260
684k
        }
Unexecuted instantiation: lebe::io::bytes::write_slice::<_, _>
Unexecuted instantiation: lebe::io::bytes::write_slice::<i8, exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>
Unexecuted instantiation: lebe::io::bytes::write_slice::<f32, exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>
Unexecuted instantiation: lebe::io::bytes::write_slice::<u8, exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>
Unexecuted instantiation: lebe::io::bytes::write_slice::<u64, exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>
lebe::io::bytes::write_slice::<i8, exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>>>
Line
Count
Source
258
324
        pub unsafe fn write_slice<T>(write: &mut impl Write, value: &[T]) -> Result<()> {
259
324
            write.write_all(slice_as_bytes(value))
260
324
        }
Unexecuted instantiation: lebe::io::bytes::write_slice::<f32, exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>>>
lebe::io::bytes::write_slice::<u8, exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>>>
Line
Count
Source
258
645k
        pub unsafe fn write_slice<T>(write: &mut impl Write, value: &[T]) -> Result<()> {
259
645k
            write.write_all(slice_as_bytes(value))
260
645k
        }
lebe::io::bytes::write_slice::<u64, exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>>>
Line
Count
Source
258
81
        pub unsafe fn write_slice<T>(write: &mut impl Write, value: &[T]) -> Result<()> {
259
81
            write.write_all(slice_as_bytes(value))
260
81
        }
261
262
        /// Read a slice of bytes into the specified slice.
263
        #[inline]
264
61.0M
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
61.0M
            read.read_exact(slice_as_bytes_mut(value))
266
61.0M
        }
Unexecuted instantiation: lebe::io::bytes::read_slice::<i8, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>>>
lebe::io::bytes::read_slice::<i8, exr::io::PeekRead<&[u8]>>
Line
Count
Source
264
187k
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
187k
            read.read_exact(slice_as_bytes_mut(value))
266
187k
        }
lebe::io::bytes::read_slice::<i8, &[u8]>
Line
Count
Source
264
2.30k
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
2.30k
            read.read_exact(slice_as_bytes_mut(value))
266
2.30k
        }
lebe::io::bytes::read_slice::<f32, &mut &mut &[u8]>
Line
Count
Source
264
58.0M
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
58.0M
            read.read_exact(slice_as_bytes_mut(value))
266
58.0M
        }
lebe::io::bytes::read_slice::<f32, &[u8]>
Line
Count
Source
264
23.9k
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
23.9k
            read.read_exact(slice_as_bytes_mut(value))
266
23.9k
        }
lebe::io::bytes::read_slice::<u8, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>>>
Line
Count
Source
264
1.86M
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
1.86M
            read.read_exact(slice_as_bytes_mut(value))
266
1.86M
        }
lebe::io::bytes::read_slice::<u8, exr::io::PeekRead<&[u8]>>
Line
Count
Source
264
1.40k
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
1.40k
            read.read_exact(slice_as_bytes_mut(value))
266
1.40k
        }
lebe::io::bytes::read_slice::<u32, &mut &mut &[u8]>
Line
Count
Source
264
67.4k
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
67.4k
            read.read_exact(slice_as_bytes_mut(value))
266
67.4k
        }
lebe::io::bytes::read_slice::<u16, &mut &mut &[u8]>
Line
Count
Source
264
173k
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
173k
            read.read_exact(slice_as_bytes_mut(value))
266
173k
        }
lebe::io::bytes::read_slice::<u64, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>>>
Line
Count
Source
264
16.7k
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
16.7k
            read.read_exact(slice_as_bytes_mut(value))
266
16.7k
        }
Unexecuted instantiation: lebe::io::bytes::read_slice::<f32, std::io::cursor::Cursor<&[u8]>>
lebe::io::bytes::read_slice::<u8, &[u8]>
Line
Count
Source
264
32.2k
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
32.2k
            read.read_exact(slice_as_bytes_mut(value))
266
32.2k
        }
Unexecuted instantiation: lebe::io::bytes::read_slice::<u32, std::io::cursor::Cursor<&[u8]>>
Unexecuted instantiation: lebe::io::bytes::read_slice::<u16, std::io::cursor::Cursor<&[u8]>>
Unexecuted instantiation: lebe::io::bytes::read_slice::<u16, &[u8]>
Unexecuted instantiation: lebe::io::bytes::read_slice::<_, _>
Unexecuted instantiation: lebe::io::bytes::read_slice::<i8, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>>
lebe::io::bytes::read_slice::<u8, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>>
Line
Count
Source
264
644k
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
644k
            read.read_exact(slice_as_bytes_mut(value))
266
644k
        }
lebe::io::bytes::read_slice::<u64, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>>
Line
Count
Source
264
84
        pub unsafe fn read_slice<T>(read: &mut impl Read, value: &mut [T]) -> Result<()> {
265
84
            read.read_exact(slice_as_bytes_mut(value))
266
84
        }
267
268
        /// View this reference as a mutable slice of bytes and write it.
269
        #[inline]
270
206M
        pub unsafe fn write_value<T: Sized>(write: &mut impl Write, value: &T) -> Result<()> {
271
206M
            write.write_all(value_as_bytes(value))
272
206M
        }
Unexecuted instantiation: lebe::io::bytes::write_value::<i32, alloc::vec::Vec<u8>>
Unexecuted instantiation: lebe::io::bytes::write_value::<u32, std::io::cursor::Cursor<alloc::vec::Vec<u8>>>
lebe::io::bytes::write_value::<u16, alloc::vec::Vec<u8>>
Line
Count
Source
270
2.17M
        pub unsafe fn write_value<T: Sized>(write: &mut impl Write, value: &T) -> Result<()> {
271
2.17M
            write.write_all(value_as_bytes(value))
272
2.17M
        }
Unexecuted instantiation: lebe::io::bytes::write_value::<u16, &mut [u8]>
Unexecuted instantiation: lebe::io::bytes::write_value::<_, _>
Unexecuted instantiation: lebe::io::bytes::write_value::<f64, exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>
Unexecuted instantiation: lebe::io::bytes::write_value::<f32, exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>
Unexecuted instantiation: lebe::io::bytes::write_value::<f32, &mut [u8]>
Unexecuted instantiation: lebe::io::bytes::write_value::<u8, exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>
Unexecuted instantiation: lebe::io::bytes::write_value::<i32, exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>
Unexecuted instantiation: lebe::io::bytes::write_value::<u32, exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>
Unexecuted instantiation: lebe::io::bytes::write_value::<u32, &mut [u8]>
Unexecuted instantiation: lebe::io::bytes::write_value::<u64, exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>
Unexecuted instantiation: lebe::io::bytes::write_value::<f64, exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>>>
lebe::io::bytes::write_value::<f32, exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>>>
Line
Count
Source
270
324
        pub unsafe fn write_value<T: Sized>(write: &mut impl Write, value: &T) -> Result<()> {
271
324
            write.write_all(value_as_bytes(value))
272
324
        }
lebe::io::bytes::write_value::<f32, &mut [u8]>
Line
Count
Source
270
200M
        pub unsafe fn write_value<T: Sized>(write: &mut impl Write, value: &T) -> Result<()> {
271
200M
            write.write_all(value_as_bytes(value))
272
200M
        }
lebe::io::bytes::write_value::<u8, exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>>>
Line
Count
Source
270
2.83k
        pub unsafe fn write_value<T: Sized>(write: &mut impl Write, value: &T) -> Result<()> {
271
2.83k
            write.write_all(value_as_bytes(value))
272
2.83k
        }
lebe::io::bytes::write_value::<i32, exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>>>
Line
Count
Source
270
3.21M
        pub unsafe fn write_value<T: Sized>(write: &mut impl Write, value: &T) -> Result<()> {
271
3.21M
            write.write_all(value_as_bytes(value))
272
3.21M
        }
lebe::io::bytes::write_value::<u32, exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>>>
Line
Count
Source
270
243
        pub unsafe fn write_value<T: Sized>(write: &mut impl Write, value: &T) -> Result<()> {
271
243
            write.write_all(value_as_bytes(value))
272
243
        }
Unexecuted instantiation: lebe::io::bytes::write_value::<u32, &mut [u8]>
Unexecuted instantiation: lebe::io::bytes::write_value::<u64, exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>>>
273
274
        /// Read a slice of bytes into the specified reference.
275
        #[inline]
276
59.3M
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
59.3M
            read.read_exact(value_as_bytes_mut(value))
278
59.3M
        }
lebe::io::bytes::read_value::<f64, &[u8]>
Line
Count
Source
276
3.07k
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
3.07k
            read.read_exact(value_as_bytes_mut(value))
278
3.07k
        }
lebe::io::bytes::read_value::<u8, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>>>
Line
Count
Source
276
46.0M
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
46.0M
            read.read_exact(value_as_bytes_mut(value))
278
46.0M
        }
lebe::io::bytes::read_value::<u8, exr::io::PeekRead<&[u8]>>
Line
Count
Source
276
1.36M
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
1.36M
            read.read_exact(value_as_bytes_mut(value))
278
1.36M
        }
lebe::io::bytes::read_value::<u8, exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>>
Line
Count
Source
276
2.01M
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
2.01M
            read.read_exact(value_as_bytes_mut(value))
278
2.01M
        }
lebe::io::bytes::read_value::<i32, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>>>
Line
Count
Source
276
1.99M
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
1.99M
            read.read_exact(value_as_bytes_mut(value))
278
1.99M
        }
lebe::io::bytes::read_value::<i32, exr::io::PeekRead<&[u8]>>
Line
Count
Source
276
594k
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
594k
            read.read_exact(value_as_bytes_mut(value))
278
594k
        }
lebe::io::bytes::read_value::<u32, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>>>
Line
Count
Source
276
8.19k
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
8.19k
            read.read_exact(value_as_bytes_mut(value))
278
8.19k
        }
Unexecuted instantiation: lebe::io::bytes::read_value::<u64, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>>>
lebe::io::bytes::read_value::<f32, &[u8]>
Line
Count
Source
276
363k
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
363k
            read.read_exact(value_as_bytes_mut(value))
278
363k
        }
lebe::io::bytes::read_value::<u8, &[u8]>
Line
Count
Source
276
712k
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
712k
            read.read_exact(value_as_bytes_mut(value))
278
712k
        }
lebe::io::bytes::read_value::<i32, &[u8]>
Line
Count
Source
276
738k
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
738k
            read.read_exact(value_as_bytes_mut(value))
278
738k
        }
lebe::io::bytes::read_value::<u32, &[u8]>
Line
Count
Source
276
132k
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
132k
            read.read_exact(value_as_bytes_mut(value))
278
132k
        }
lebe::io::bytes::read_value::<u16, &[u8]>
Line
Count
Source
276
2.17M
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
2.17M
            read.read_exact(value_as_bytes_mut(value))
278
2.17M
        }
Unexecuted instantiation: lebe::io::bytes::read_value::<_, _>
lebe::io::bytes::read_value::<u8, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>>
Line
Count
Source
276
16.9k
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
16.9k
            read.read_exact(value_as_bytes_mut(value))
278
16.9k
        }
lebe::io::bytes::read_value::<u8, exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>
Line
Count
Source
276
972
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
972
            read.read_exact(value_as_bytes_mut(value))
278
972
        }
lebe::io::bytes::read_value::<i32, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>>
Line
Count
Source
276
3.21M
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
3.21M
            read.read_exact(value_as_bytes_mut(value))
278
3.21M
        }
lebe::io::bytes::read_value::<u32, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>>
Line
Count
Source
276
81
        pub unsafe fn read_value<T: Sized>(read: &mut impl Read, value: &mut T) -> Result<()> {
277
81
            read.read_exact(value_as_bytes_mut(value))
278
81
        }
Unexecuted instantiation: lebe::io::bytes::read_value::<u64, exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>>
279
    }
280
281
    /// A `std::io::Write` output stream which supports writing any primitive values as bytes.
282
    /// Will encode the values to be either little endian or big endian, as desired.
283
    ///
284
    /// This extension trait is implemented for all `Write` types.
285
    /// Add `use lebe::io::WriteEndian;` to your code
286
    /// to automatically unlock this functionality for all types that implement `Write`.
287
    pub trait WriteEndian<T: ?Sized> {
288
289
        /// Write the byte value of the specified reference, converting it to little endianness
290
        fn write_as_little_endian(&mut self, value: &T) -> Result<()>;
291
292
        /// Write the byte value of the specified reference, converting it to big endianness
293
        fn write_as_big_endian(&mut self, value: &T) -> Result<()>;
294
295
        /// Write the byte value of the specified reference, not converting it
296
203M
        fn write_as_native_endian(&mut self, value: &T) -> Result<()> {
297
203M
            #[cfg(target_endian = "little")] { self.write_as_little_endian(value) }
298
            #[cfg(target_endian = "big")] { self.write_as_big_endian(value) }
299
203M
        }
<alloc::vec::Vec<u8> as lebe::io::WriteEndian<[u8]>>::write_as_native_endian
Line
Count
Source
296
284
        fn write_as_native_endian(&mut self, value: &T) -> Result<()> {
297
284
            #[cfg(target_endian = "little")] { self.write_as_little_endian(value) }
298
            #[cfg(target_endian = "big")] { self.write_as_big_endian(value) }
299
284
        }
<alloc::vec::Vec<u8> as lebe::io::WriteEndian<u16>>::write_as_native_endian
Line
Count
Source
296
2.17M
        fn write_as_native_endian(&mut self, value: &T) -> Result<()> {
297
2.17M
            #[cfg(target_endian = "little")] { self.write_as_little_endian(value) }
298
            #[cfg(target_endian = "big")] { self.write_as_big_endian(value) }
299
2.17M
        }
<&mut [u8] as lebe::io::WriteEndian<[u16]>>::write_as_native_endian
Line
Count
Source
296
684k
        fn write_as_native_endian(&mut self, value: &T) -> Result<()> {
297
684k
            #[cfg(target_endian = "little")] { self.write_as_little_endian(value) }
298
            #[cfg(target_endian = "big")] { self.write_as_big_endian(value) }
299
684k
        }
Unexecuted instantiation: <std::io::cursor::Cursor<&mut [u8]> as lebe::io::WriteEndian<[f32]>>::write_as_native_endian
Unexecuted instantiation: <std::io::cursor::Cursor<&mut [u8]> as lebe::io::WriteEndian<[u32]>>::write_as_native_endian
Unexecuted instantiation: <std::io::cursor::Cursor<&mut [u8]> as lebe::io::WriteEndian<[u16]>>::write_as_native_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<_>>::write_as_native_endian
Unexecuted instantiation: <exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<[u8]>>::write_as_native_endian
Unexecuted instantiation: <&mut [u8] as lebe::io::WriteEndian<f32>>::write_as_native_endian
Unexecuted instantiation: <&mut [u8] as lebe::io::WriteEndian<u32>>::write_as_native_endian
Unexecuted instantiation: <&mut [u8] as lebe::io::WriteEndian<u16>>::write_as_native_endian
<&mut [u8] as lebe::io::WriteEndian<f32>>::write_as_native_endian
Line
Count
Source
296
200M
        fn write_as_native_endian(&mut self, value: &T) -> Result<()> {
297
200M
            #[cfg(target_endian = "little")] { self.write_as_little_endian(value) }
298
            #[cfg(target_endian = "big")] { self.write_as_big_endian(value) }
299
200M
        }
Unexecuted instantiation: <&mut [u8] as lebe::io::WriteEndian<u32>>::write_as_native_endian
Unexecuted instantiation: <&mut [u8] as lebe::io::WriteEndian<u16>>::write_as_native_endian
<exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<[u8]>>::write_as_native_endian
Line
Count
Source
296
81
        fn write_as_native_endian(&mut self, value: &T) -> Result<()> {
297
81
            #[cfg(target_endian = "little")] { self.write_as_little_endian(value) }
298
            #[cfg(target_endian = "big")] { self.write_as_big_endian(value) }
299
81
        }
300
    }
301
302
    /// A `std::io::Read` input stream which supports reading any primitive values from bytes.
303
    /// Will decode the values from either little endian or big endian, as desired.
304
    ///
305
    /// This extension trait is implemented for all `Read` types.
306
    /// Add `use lebe::io::ReadEndian;` to your code
307
    /// to automatically unlock this functionality for all types that implement `Read`.
308
    pub trait ReadEndian<T: ?Sized> {
309
310
        /// Read into the supplied reference. Acts the same as `std::io::Read::read_exact`.
311
        fn read_from_little_endian_into(&mut self, value: &mut T) -> Result<()>;
312
313
        /// Read into the supplied reference. Acts the same as `std::io::Read::read_exact`.
314
        fn read_from_big_endian_into(&mut self, value: &mut T) -> Result<()>;
315
316
        /// Read into the supplied reference. Acts the same as `std::io::Read::read_exact`.
317
58.2M
        fn read_from_native_endian_into(&mut self, value: &mut T) -> Result<()> {
318
58.2M
            #[cfg(target_endian = "little")] { self.read_from_little_endian_into(value) }
319
            #[cfg(target_endian = "big")] { self.read_from_big_endian_into(value) }
320
58.2M
        }
<&mut &mut &[u8] as lebe::io::ReadEndian<[f32]>>::read_from_native_endian_into
Line
Count
Source
317
58.0M
        fn read_from_native_endian_into(&mut self, value: &mut T) -> Result<()> {
318
58.0M
            #[cfg(target_endian = "little")] { self.read_from_little_endian_into(value) }
319
            #[cfg(target_endian = "big")] { self.read_from_big_endian_into(value) }
320
58.0M
        }
<&mut &mut &[u8] as lebe::io::ReadEndian<[u32]>>::read_from_native_endian_into
Line
Count
Source
317
67.4k
        fn read_from_native_endian_into(&mut self, value: &mut T) -> Result<()> {
318
67.4k
            #[cfg(target_endian = "little")] { self.read_from_little_endian_into(value) }
319
            #[cfg(target_endian = "big")] { self.read_from_big_endian_into(value) }
320
67.4k
        }
<&mut &mut &[u8] as lebe::io::ReadEndian<[u16]>>::read_from_native_endian_into
Line
Count
Source
317
173k
        fn read_from_native_endian_into(&mut self, value: &mut T) -> Result<()> {
318
173k
            #[cfg(target_endian = "little")] { self.read_from_little_endian_into(value) }
319
            #[cfg(target_endian = "big")] { self.read_from_big_endian_into(value) }
320
173k
        }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<[u8]>>::read_from_native_endian_into
Line
Count
Source
317
8.19k
        fn read_from_native_endian_into(&mut self, value: &mut T) -> Result<()> {
318
8.19k
            #[cfg(target_endian = "little")] { self.read_from_little_endian_into(value) }
319
            #[cfg(target_endian = "big")] { self.read_from_big_endian_into(value) }
320
8.19k
        }
<&[u8] as lebe::io::ReadEndian<[u8]>>::read_from_native_endian_into
Line
Count
Source
317
46
        fn read_from_native_endian_into(&mut self, value: &mut T) -> Result<()> {
318
46
            #[cfg(target_endian = "little")] { self.read_from_little_endian_into(value) }
319
            #[cfg(target_endian = "big")] { self.read_from_big_endian_into(value) }
320
46
        }
Unexecuted instantiation: <&[u8] as lebe::io::ReadEndian<[u16]>>::read_from_native_endian_into
Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as lebe::io::ReadEndian<[f32]>>::read_from_native_endian_into
Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as lebe::io::ReadEndian<[u32]>>::read_from_native_endian_into
Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as lebe::io::ReadEndian<[u16]>>::read_from_native_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<_>>::read_from_native_endian_into
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<[u8]>>::read_from_native_endian_into
Line
Count
Source
317
81
        fn read_from_native_endian_into(&mut self, value: &mut T) -> Result<()> {
318
81
            #[cfg(target_endian = "little")] { self.read_from_little_endian_into(value) }
319
            #[cfg(target_endian = "big")] { self.read_from_big_endian_into(value) }
320
81
        }
321
322
        /// Read the byte value of the inferred type
323
        #[inline]
324
59.3M
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
59.3M
            let mut value = T::default();
326
59.3M
            self.read_from_little_endian_into(&mut value)?;
327
59.3M
            Ok(value)
328
59.3M
        }
<&[u8] as lebe::io::ReadEndian<f64>>::read_from_little_endian
Line
Count
Source
324
3.07k
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
3.07k
            let mut value = T::default();
326
3.07k
            self.read_from_little_endian_into(&mut value)?;
327
3.07k
            Ok(value)
328
3.07k
        }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<u8>>::read_from_little_endian
Line
Count
Source
324
46.0M
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
46.0M
            let mut value = T::default();
326
46.0M
            self.read_from_little_endian_into(&mut value)?;
327
46.0M
            Ok(value)
328
46.0M
        }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<i32>>::read_from_little_endian
Line
Count
Source
324
1.99M
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
1.99M
            let mut value = T::default();
326
1.99M
            self.read_from_little_endian_into(&mut value)?;
327
1.99M
            Ok(value)
328
1.99M
        }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<u32>>::read_from_little_endian
Line
Count
Source
324
8.19k
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
8.19k
            let mut value = T::default();
326
8.19k
            self.read_from_little_endian_into(&mut value)?;
327
8.18k
            Ok(value)
328
8.19k
        }
Unexecuted instantiation: <exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<u64>>::read_from_little_endian
<exr::io::PeekRead<&[u8]> as lebe::io::ReadEndian<u8>>::read_from_little_endian
Line
Count
Source
324
1.36M
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
1.36M
            let mut value = T::default();
326
1.36M
            self.read_from_little_endian_into(&mut value)?;
327
1.36M
            Ok(value)
328
1.36M
        }
<exr::io::PeekRead<&[u8]> as lebe::io::ReadEndian<i32>>::read_from_little_endian
Line
Count
Source
324
594k
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
594k
            let mut value = T::default();
326
594k
            self.read_from_little_endian_into(&mut value)?;
327
594k
            Ok(value)
328
594k
        }
<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>> as lebe::io::ReadEndian<u8>>::read_from_little_endian
Line
Count
Source
324
2.01M
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
2.01M
            let mut value = T::default();
326
2.01M
            self.read_from_little_endian_into(&mut value)?;
327
2.01M
            Ok(value)
328
2.01M
        }
<&[u8] as lebe::io::ReadEndian<f32>>::read_from_little_endian
Line
Count
Source
324
363k
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
363k
            let mut value = T::default();
326
363k
            self.read_from_little_endian_into(&mut value)?;
327
363k
            Ok(value)
328
363k
        }
<&[u8] as lebe::io::ReadEndian<u8>>::read_from_little_endian
Line
Count
Source
324
712k
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
712k
            let mut value = T::default();
326
712k
            self.read_from_little_endian_into(&mut value)?;
327
712k
            Ok(value)
328
712k
        }
<&[u8] as lebe::io::ReadEndian<i32>>::read_from_little_endian
Line
Count
Source
324
738k
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
738k
            let mut value = T::default();
326
738k
            self.read_from_little_endian_into(&mut value)?;
327
738k
            Ok(value)
328
738k
        }
<&[u8] as lebe::io::ReadEndian<u32>>::read_from_little_endian
Line
Count
Source
324
132k
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
132k
            let mut value = T::default();
326
132k
            self.read_from_little_endian_into(&mut value)?;
327
132k
            Ok(value)
328
132k
        }
<&[u8] as lebe::io::ReadEndian<u16>>::read_from_little_endian
Line
Count
Source
324
2.17M
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
2.17M
            let mut value = T::default();
326
2.17M
            self.read_from_little_endian_into(&mut value)?;
327
2.17M
            Ok(value)
328
2.17M
        }
Unexecuted instantiation: <_ as lebe::io::ReadEndian<_>>::read_from_little_endian
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<u8>>::read_from_little_endian
Line
Count
Source
324
16.9k
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
16.9k
            let mut value = T::default();
326
16.9k
            self.read_from_little_endian_into(&mut value)?;
327
16.9k
            Ok(value)
328
16.9k
        }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<i32>>::read_from_little_endian
Line
Count
Source
324
3.21M
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
3.21M
            let mut value = T::default();
326
3.21M
            self.read_from_little_endian_into(&mut value)?;
327
3.21M
            Ok(value)
328
3.21M
        }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<u32>>::read_from_little_endian
Line
Count
Source
324
81
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
81
            let mut value = T::default();
326
81
            self.read_from_little_endian_into(&mut value)?;
327
81
            Ok(value)
328
81
        }
Unexecuted instantiation: <exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<u64>>::read_from_little_endian
<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::ReadEndian<u8>>::read_from_little_endian
Line
Count
Source
324
972
        fn read_from_little_endian(&mut self) -> Result<T> where T: Sized + Default {
325
972
            let mut value = T::default();
326
972
            self.read_from_little_endian_into(&mut value)?;
327
972
            Ok(value)
328
972
        }
329
330
        /// Read the byte value of the inferred type
331
        #[inline]
332
0
        fn read_from_big_endian(&mut self) -> Result<T> where T: Sized + Default {
333
0
            let mut value = T::default();
334
0
            self.read_from_big_endian_into(&mut value)?;
335
0
            Ok(value)
336
0
        }
337
338
        /// Read the byte value of the inferred type
339
        #[inline]
340
354k
        fn read_from_native_endian(&mut self) -> Result<T> where T: Sized + Default {
341
354k
            #[cfg(target_endian = "little")] { self.read_from_little_endian() }
342
            #[cfg(target_endian = "big")] { self.read_from_big_endian() }
343
354k
        }
Unexecuted instantiation: <&[u8] as lebe::io::ReadEndian<f32>>::read_from_native_endian
<&[u8] as lebe::io::ReadEndian<u8>>::read_from_native_endian
Line
Count
Source
340
354k
        fn read_from_native_endian(&mut self) -> Result<T> where T: Sized + Default {
341
354k
            #[cfg(target_endian = "little")] { self.read_from_little_endian() }
342
            #[cfg(target_endian = "big")] { self.read_from_big_endian() }
343
354k
        }
Unexecuted instantiation: <&[u8] as lebe::io::ReadEndian<u32>>::read_from_native_endian
Unexecuted instantiation: <&[u8] as lebe::io::ReadEndian<u16>>::read_from_native_endian
Unexecuted instantiation: <_ as lebe::io::ReadEndian<_>>::read_from_native_endian
344
    }
345
346
    // implement primitive for all types that are implemented by `Read`
347
    impl<R: Read + ReadEndian<P>, P: Default> ReadPrimitive<R> for P {}
348
349
350
    /// Offers a prettier versions of reading a primitive number.
351
    ///
352
    /// The default way of reading a value is:
353
    /// ```rust
354
    /// # use std::io::Read;
355
    /// # use lebe::prelude::*;
356
    /// # let mut reader : &[u8] = &[2, 1];
357
    ///
358
    /// let number: u16 = reader.read_from_little_endian()?;
359
    /// println!("{}", number);
360
    /// # Ok::<(), std::io::Error>(())
361
    ///
362
    /// ```
363
    ///
364
    /// This trait enables you to use expressions:
365
    /// ```rust
366
    /// # use std::io::Read;
367
    /// # use lebe::prelude::*;
368
    /// # let mut reader : &[u8] = &[2, 1];
369
    ///
370
    /// println!("{}", u16::read_from_little_endian(&mut reader)?);
371
    /// # Ok::<(), std::io::Error>(())
372
    /// ```
373
    /// .
374
    ///
375
    pub trait ReadPrimitive<R: Read + ReadEndian<Self>> : Sized + Default {
376
        /// Read this value from the supplied reader. Same as `ReadEndian::read_from_little_endian()`.
377
4.44M
        fn read_from_little_endian(read: &mut R) -> Result<Self> {
378
4.44M
            read.read_from_little_endian()
379
4.44M
        }
<u8 as lebe::io::ReadPrimitive<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>>>::read_from_little_endian
Line
Count
Source
377
2.01M
        fn read_from_little_endian(read: &mut R) -> Result<Self> {
378
2.01M
            read.read_from_little_endian()
379
2.01M
        }
<u8 as lebe::io::ReadPrimitive<&[u8]>>::read_from_little_endian
Line
Count
Source
377
262k
        fn read_from_little_endian(read: &mut R) -> Result<Self> {
378
262k
            read.read_from_little_endian()
379
262k
        }
<u16 as lebe::io::ReadPrimitive<&[u8]>>::read_from_little_endian
Line
Count
Source
377
2.17M
        fn read_from_little_endian(read: &mut R) -> Result<Self> {
378
2.17M
            read.read_from_little_endian()
379
2.17M
        }
Unexecuted instantiation: <_ as lebe::io::ReadPrimitive<_>>::read_from_little_endian
<u8 as lebe::io::ReadPrimitive<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>>::read_from_little_endian
Line
Count
Source
377
972
        fn read_from_little_endian(read: &mut R) -> Result<Self> {
378
972
            read.read_from_little_endian()
379
972
        }
380
381
        /// Read this value from the supplied reader. Same as `ReadEndian::read_from_big_endian()`.
382
0
        fn read_from_big_endian(read: &mut R) -> Result<Self> {
383
0
            read.read_from_big_endian()
384
0
        }
385
386
        /// Read this value from the supplied reader. Same as `ReadEndian::read_from_native_endian()`.
387
0
        fn read_from_native_endian(read: &mut R) -> Result<Self> {
388
0
            read.read_from_native_endian()
389
0
        }
Unexecuted instantiation: <f32 as lebe::io::ReadPrimitive<&[u8]>>::read_from_native_endian
Unexecuted instantiation: <u32 as lebe::io::ReadPrimitive<&[u8]>>::read_from_native_endian
Unexecuted instantiation: <u16 as lebe::io::ReadPrimitive<&[u8]>>::read_from_native_endian
Unexecuted instantiation: <_ as lebe::io::ReadPrimitive<_>>::read_from_native_endian
390
    }
391
392
    macro_rules! implement_simple_primitive_write {
393
        ($type: ident) => {
394
            impl<W: Write> WriteEndian<$type> for W {
395
206M
                fn write_as_little_endian(&mut self, value: &$type) -> Result<()> {
396
206M
                    unsafe { bytes::write_value(self, &value.from_current_into_little_endian()) }
397
206M
                }
<alloc::vec::Vec<u8> as lebe::io::WriteEndian<u16>>::write_as_little_endian
Line
Count
Source
395
2.17M
                fn write_as_little_endian(&mut self, value: &$type) -> Result<()> {
396
2.17M
                    unsafe { bytes::write_value(self, &value.from_current_into_little_endian()) }
397
2.17M
                }
Unexecuted instantiation: <alloc::vec::Vec<u8> as lebe::io::WriteEndian<i32>>::write_as_little_endian
Unexecuted instantiation: <&mut [u8] as lebe::io::WriteEndian<u16>>::write_as_little_endian
Unexecuted instantiation: <std::io::cursor::Cursor<alloc::vec::Vec<u8>> as lebe::io::WriteEndian<u32>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<u16>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<u32>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<u64>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<u128>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<i8>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<u8>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<i16>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<i32>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<i64>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<i128>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<f32>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<f64>>::write_as_little_endian
Unexecuted instantiation: <exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<u32>>::write_as_little_endian
Unexecuted instantiation: <exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<u64>>::write_as_little_endian
Unexecuted instantiation: <exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<u8>>::write_as_little_endian
Unexecuted instantiation: <exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<i32>>::write_as_little_endian
Unexecuted instantiation: <exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<f32>>::write_as_little_endian
Unexecuted instantiation: <exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<f64>>::write_as_little_endian
Unexecuted instantiation: <&mut [u8] as lebe::io::WriteEndian<u32>>::write_as_little_endian
Unexecuted instantiation: <&mut [u8] as lebe::io::WriteEndian<f32>>::write_as_little_endian
Unexecuted instantiation: <&mut [u8] as lebe::io::WriteEndian<u32>>::write_as_little_endian
<&mut [u8] as lebe::io::WriteEndian<f32>>::write_as_little_endian
Line
Count
Source
395
200M
                fn write_as_little_endian(&mut self, value: &$type) -> Result<()> {
396
200M
                    unsafe { bytes::write_value(self, &value.from_current_into_little_endian()) }
397
200M
                }
<exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<u32>>::write_as_little_endian
Line
Count
Source
395
243
                fn write_as_little_endian(&mut self, value: &$type) -> Result<()> {
396
243
                    unsafe { bytes::write_value(self, &value.from_current_into_little_endian()) }
397
243
                }
Unexecuted instantiation: <exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<u64>>::write_as_little_endian
<exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<u8>>::write_as_little_endian
Line
Count
Source
395
2.83k
                fn write_as_little_endian(&mut self, value: &$type) -> Result<()> {
396
2.83k
                    unsafe { bytes::write_value(self, &value.from_current_into_little_endian()) }
397
2.83k
                }
<exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<i32>>::write_as_little_endian
Line
Count
Source
395
3.21M
                fn write_as_little_endian(&mut self, value: &$type) -> Result<()> {
396
3.21M
                    unsafe { bytes::write_value(self, &value.from_current_into_little_endian()) }
397
3.21M
                }
<exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<f32>>::write_as_little_endian
Line
Count
Source
395
324
                fn write_as_little_endian(&mut self, value: &$type) -> Result<()> {
396
324
                    unsafe { bytes::write_value(self, &value.from_current_into_little_endian()) }
397
324
                }
Unexecuted instantiation: <exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<f64>>::write_as_little_endian
398
399
0
                fn write_as_big_endian(&mut self, value: &$type) -> Result<()> {
400
0
                    unsafe { bytes::write_value(self, &value.from_current_into_big_endian()) }
401
0
                }
Unexecuted instantiation: <_ as lebe::io::WriteEndian<u16>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<u32>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<u64>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<u128>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<i8>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<u8>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<i16>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<i32>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<i64>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<i128>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<f32>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<f64>>::write_as_big_endian
402
            }
403
404
            impl<R: Read> ReadEndian<$type> for R {
405
                #[inline]
406
59.3M
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
59.3M
                    unsafe { bytes::read_value(self, value)?; }
408
59.3M
                    value.convert_little_endian_to_current();
409
59.3M
                    Ok(())
410
59.3M
                }
<&[u8] as lebe::io::ReadEndian<f64>>::read_from_little_endian_into
Line
Count
Source
406
3.07k
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
3.07k
                    unsafe { bytes::read_value(self, value)?; }
408
3.07k
                    value.convert_little_endian_to_current();
409
3.07k
                    Ok(())
410
3.07k
                }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<u8>>::read_from_little_endian_into
Line
Count
Source
406
46.0M
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
46.0M
                    unsafe { bytes::read_value(self, value)?; }
408
46.0M
                    value.convert_little_endian_to_current();
409
46.0M
                    Ok(())
410
46.0M
                }
<exr::io::PeekRead<&[u8]> as lebe::io::ReadEndian<u8>>::read_from_little_endian_into
Line
Count
Source
406
1.36M
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
1.36M
                    unsafe { bytes::read_value(self, value)?; }
408
1.36M
                    value.convert_little_endian_to_current();
409
1.36M
                    Ok(())
410
1.36M
                }
<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>> as lebe::io::ReadEndian<u8>>::read_from_little_endian_into
Line
Count
Source
406
2.01M
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
2.01M
                    unsafe { bytes::read_value(self, value)?; }
408
2.01M
                    value.convert_little_endian_to_current();
409
2.01M
                    Ok(())
410
2.01M
                }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<u32>>::read_from_little_endian_into
Line
Count
Source
406
8.19k
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
8.19k
                    unsafe { bytes::read_value(self, value)?; }
408
8.18k
                    value.convert_little_endian_to_current();
409
8.18k
                    Ok(())
410
8.19k
                }
Unexecuted instantiation: <exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<u64>>::read_from_little_endian_into
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<i32>>::read_from_little_endian_into
Line
Count
Source
406
1.99M
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
1.99M
                    unsafe { bytes::read_value(self, value)?; }
408
1.99M
                    value.convert_little_endian_to_current();
409
1.99M
                    Ok(())
410
1.99M
                }
<exr::io::PeekRead<&[u8]> as lebe::io::ReadEndian<i32>>::read_from_little_endian_into
Line
Count
Source
406
594k
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
594k
                    unsafe { bytes::read_value(self, value)?; }
408
594k
                    value.convert_little_endian_to_current();
409
594k
                    Ok(())
410
594k
                }
<&[u8] as lebe::io::ReadEndian<u8>>::read_from_little_endian_into
Line
Count
Source
406
712k
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
712k
                    unsafe { bytes::read_value(self, value)?; }
408
712k
                    value.convert_little_endian_to_current();
409
712k
                    Ok(())
410
712k
                }
<&[u8] as lebe::io::ReadEndian<u16>>::read_from_little_endian_into
Line
Count
Source
406
2.17M
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
2.17M
                    unsafe { bytes::read_value(self, value)?; }
408
2.17M
                    value.convert_little_endian_to_current();
409
2.17M
                    Ok(())
410
2.17M
                }
<&[u8] as lebe::io::ReadEndian<u32>>::read_from_little_endian_into
Line
Count
Source
406
132k
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
132k
                    unsafe { bytes::read_value(self, value)?; }
408
132k
                    value.convert_little_endian_to_current();
409
132k
                    Ok(())
410
132k
                }
<&[u8] as lebe::io::ReadEndian<i32>>::read_from_little_endian_into
Line
Count
Source
406
738k
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
738k
                    unsafe { bytes::read_value(self, value)?; }
408
738k
                    value.convert_little_endian_to_current();
409
738k
                    Ok(())
410
738k
                }
<&[u8] as lebe::io::ReadEndian<f32>>::read_from_little_endian_into
Line
Count
Source
406
363k
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
363k
                    unsafe { bytes::read_value(self, value)?; }
408
363k
                    value.convert_little_endian_to_current();
409
363k
                    Ok(())
410
363k
                }
Unexecuted instantiation: <_ as lebe::io::ReadEndian<u8>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<u16>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<u32>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<u64>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<u128>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<i8>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<i16>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<i32>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<i64>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<i128>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<f32>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<f64>>::read_from_little_endian_into
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<u8>>::read_from_little_endian_into
Line
Count
Source
406
16.9k
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
16.9k
                    unsafe { bytes::read_value(self, value)?; }
408
16.9k
                    value.convert_little_endian_to_current();
409
16.9k
                    Ok(())
410
16.9k
                }
<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::ReadEndian<u8>>::read_from_little_endian_into
Line
Count
Source
406
972
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
972
                    unsafe { bytes::read_value(self, value)?; }
408
972
                    value.convert_little_endian_to_current();
409
972
                    Ok(())
410
972
                }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<u32>>::read_from_little_endian_into
Line
Count
Source
406
81
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
81
                    unsafe { bytes::read_value(self, value)?; }
408
81
                    value.convert_little_endian_to_current();
409
81
                    Ok(())
410
81
                }
Unexecuted instantiation: <exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<u64>>::read_from_little_endian_into
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<i32>>::read_from_little_endian_into
Line
Count
Source
406
3.21M
                fn read_from_little_endian_into(&mut self, value: &mut $type) -> Result<()> {
407
3.21M
                    unsafe { bytes::read_value(self, value)?; }
408
3.21M
                    value.convert_little_endian_to_current();
409
3.21M
                    Ok(())
410
3.21M
                }
411
412
                #[inline]
413
0
                fn read_from_big_endian_into(&mut self, value: &mut $type) -> Result<()> {
414
0
                    unsafe { bytes::read_value(self, value)?; }
415
0
                    value.convert_big_endian_to_current();
416
0
                    Ok(())
417
0
                }
Unexecuted instantiation: <_ as lebe::io::ReadEndian<u8>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<u16>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<u32>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<u64>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<u128>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<i8>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<i16>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<i32>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<i64>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<i128>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<f32>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<f64>>::read_from_big_endian_into
418
            }
419
        };
420
    }
421
422
    call_single_arg_macro_for_each! {
423
        implement_simple_primitive_write,
424
        u8, u16, u32, u64, u128,
425
        i8, i16, i32, i64, i128,
426
        f32, f64
427
    }
428
429
430
    macro_rules! implement_slice_io {
431
        ($type: ident) => {
432
            impl<W: Write> WriteEndian<[$type]> for W {
433
1.33M
                fn write_as_little_endian(&mut self, value: &[$type]) -> Result<()> {
434
                    #[cfg(target_endian = "big")] {
435
                        for number in value { // TODO SIMD!
436
                            self.write_as_little_endian(number)?;
437
                        }
438
                    }
439
440
                    // else write whole slice
441
                    #[cfg(target_endian = "little")]
442
1.33M
                    unsafe { bytes::write_slice(self, value)?; }
443
444
1.33M
                    Ok(())
445
1.33M
                }
<alloc::vec::Vec<u8> as lebe::io::WriteEndian<[u8]>>::write_as_little_endian
Line
Count
Source
433
284
                fn write_as_little_endian(&mut self, value: &[$type]) -> Result<()> {
434
                    #[cfg(target_endian = "big")] {
435
                        for number in value { // TODO SIMD!
436
                            self.write_as_little_endian(number)?;
437
                        }
438
                    }
439
440
                    // else write whole slice
441
                    #[cfg(target_endian = "little")]
442
284
                    unsafe { bytes::write_slice(self, value)?; }
443
444
284
                    Ok(())
445
284
                }
Unexecuted instantiation: <alloc::vec::Vec<u8> as lebe::io::WriteEndian<[u16]>>::write_as_little_endian
<&mut [u8] as lebe::io::WriteEndian<[u16]>>::write_as_little_endian
Line
Count
Source
433
684k
                fn write_as_little_endian(&mut self, value: &[$type]) -> Result<()> {
434
                    #[cfg(target_endian = "big")] {
435
                        for number in value { // TODO SIMD!
436
                            self.write_as_little_endian(number)?;
437
                        }
438
                    }
439
440
                    // else write whole slice
441
                    #[cfg(target_endian = "little")]
442
684k
                    unsafe { bytes::write_slice(self, value)?; }
443
444
684k
                    Ok(())
445
684k
                }
Unexecuted instantiation: <std::io::cursor::Cursor<&mut [u8]> as lebe::io::WriteEndian<[f32]>>::write_as_little_endian
Unexecuted instantiation: <std::io::cursor::Cursor<&mut [u8]> as lebe::io::WriteEndian<[u16]>>::write_as_little_endian
Unexecuted instantiation: <std::io::cursor::Cursor<alloc::vec::Vec<u8>> as lebe::io::WriteEndian<[u32]>>::write_as_little_endian
Unexecuted instantiation: <std::io::cursor::Cursor<&mut [u8]> as lebe::io::WriteEndian<[u32]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[i32]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[i64]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[i128]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[f64]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[f32]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[u8]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[u16]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[u32]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[u64]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[u128]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[i8]>>::write_as_little_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[i16]>>::write_as_little_endian
Unexecuted instantiation: <exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<[f32]>>::write_as_little_endian
Unexecuted instantiation: <exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<[u8]>>::write_as_little_endian
Unexecuted instantiation: <exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<[u64]>>::write_as_little_endian
Unexecuted instantiation: <exr::io::Tracking<&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<[i8]>>::write_as_little_endian
Unexecuted instantiation: <exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<[f32]>>::write_as_little_endian
<exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<[u8]>>::write_as_little_endian
Line
Count
Source
433
645k
                fn write_as_little_endian(&mut self, value: &[$type]) -> Result<()> {
434
                    #[cfg(target_endian = "big")] {
435
                        for number in value { // TODO SIMD!
436
                            self.write_as_little_endian(number)?;
437
                        }
438
                    }
439
440
                    // else write whole slice
441
                    #[cfg(target_endian = "little")]
442
645k
                    unsafe { bytes::write_slice(self, value)?; }
443
444
645k
                    Ok(())
445
645k
                }
<exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<[u64]>>::write_as_little_endian
Line
Count
Source
433
81
                fn write_as_little_endian(&mut self, value: &[$type]) -> Result<()> {
434
                    #[cfg(target_endian = "big")] {
435
                        for number in value { // TODO SIMD!
436
                            self.write_as_little_endian(number)?;
437
                        }
438
                    }
439
440
                    // else write whole slice
441
                    #[cfg(target_endian = "little")]
442
81
                    unsafe { bytes::write_slice(self, value)?; }
443
444
81
                    Ok(())
445
81
                }
<exr::io::Tracking<&mut std::io::cursor::Cursor<&mut alloc::vec::Vec<u8>>> as lebe::io::WriteEndian<[i8]>>::write_as_little_endian
Line
Count
Source
433
324
                fn write_as_little_endian(&mut self, value: &[$type]) -> Result<()> {
434
                    #[cfg(target_endian = "big")] {
435
                        for number in value { // TODO SIMD!
436
                            self.write_as_little_endian(number)?;
437
                        }
438
                    }
439
440
                    // else write whole slice
441
                    #[cfg(target_endian = "little")]
442
324
                    unsafe { bytes::write_slice(self, value)?; }
443
444
324
                    Ok(())
445
324
                }
446
447
0
                fn write_as_big_endian(&mut self, value: &[$type]) -> Result<()> {
448
                    #[cfg(target_endian = "little")] {
449
0
                        for number in value { // TODO SIMD!
450
0
                            self.write_as_big_endian(number)?;
451
                        }
452
                    }
453
454
                    // else write whole slice
455
                    #[cfg(target_endian = "big")]
456
                    unsafe { bytes::write_slice(self, value)?; }
457
458
0
                    Ok(())
459
0
                }
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[i32]>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[i64]>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[i128]>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[f64]>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[f32]>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[u8]>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[u16]>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[u32]>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[u64]>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[u128]>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[i8]>>::write_as_big_endian
Unexecuted instantiation: <_ as lebe::io::WriteEndian<[i16]>>::write_as_big_endian
460
            }
461
462
            impl<R: Read> ReadEndian<[$type]> for R {
463
61.0M
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
61.0M
                    unsafe { bytes::read_slice(self, value)? };
465
61.0M
                    value.convert_little_endian_to_current();
466
61.0M
                    Ok(())
467
61.0M
                }
<&mut &mut &[u8] as lebe::io::ReadEndian<[f32]>>::read_from_little_endian_into
Line
Count
Source
463
58.0M
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
58.0M
                    unsafe { bytes::read_slice(self, value)? };
465
58.0M
                    value.convert_little_endian_to_current();
466
58.0M
                    Ok(())
467
58.0M
                }
<&[u8] as lebe::io::ReadEndian<[f32]>>::read_from_little_endian_into
Line
Count
Source
463
23.9k
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
23.9k
                    unsafe { bytes::read_slice(self, value)? };
465
23.9k
                    value.convert_little_endian_to_current();
466
23.9k
                    Ok(())
467
23.9k
                }
<&mut &mut &[u8] as lebe::io::ReadEndian<[u16]>>::read_from_little_endian_into
Line
Count
Source
463
173k
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
173k
                    unsafe { bytes::read_slice(self, value)? };
465
173k
                    value.convert_little_endian_to_current();
466
173k
                    Ok(())
467
173k
                }
<&mut &mut &[u8] as lebe::io::ReadEndian<[u32]>>::read_from_little_endian_into
Line
Count
Source
463
67.4k
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
67.4k
                    unsafe { bytes::read_slice(self, value)? };
465
67.4k
                    value.convert_little_endian_to_current();
466
67.4k
                    Ok(())
467
67.4k
                }
<&[u8] as lebe::io::ReadEndian<[i8]>>::read_from_little_endian_into
Line
Count
Source
463
2.30k
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
2.30k
                    unsafe { bytes::read_slice(self, value)? };
465
2.30k
                    value.convert_little_endian_to_current();
466
2.30k
                    Ok(())
467
2.30k
                }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<[u8]>>::read_from_little_endian_into
Line
Count
Source
463
1.86M
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
1.86M
                    unsafe { bytes::read_slice(self, value)? };
465
1.86M
                    value.convert_little_endian_to_current();
466
1.86M
                    Ok(())
467
1.86M
                }
<exr::io::PeekRead<&[u8]> as lebe::io::ReadEndian<[u8]>>::read_from_little_endian_into
Line
Count
Source
463
1.40k
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
1.40k
                    unsafe { bytes::read_slice(self, value)? };
465
1.39k
                    value.convert_little_endian_to_current();
466
1.39k
                    Ok(())
467
1.40k
                }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<[u64]>>::read_from_little_endian_into
Line
Count
Source
463
16.7k
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
16.7k
                    unsafe { bytes::read_slice(self, value)? };
465
16.5k
                    value.convert_little_endian_to_current();
466
16.5k
                    Ok(())
467
16.7k
                }
Unexecuted instantiation: <exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<&[u8]>>> as lebe::io::ReadEndian<[i8]>>::read_from_little_endian_into
<exr::io::PeekRead<&[u8]> as lebe::io::ReadEndian<[i8]>>::read_from_little_endian_into
Line
Count
Source
463
187k
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
187k
                    unsafe { bytes::read_slice(self, value)? };
465
187k
                    value.convert_little_endian_to_current();
466
187k
                    Ok(())
467
187k
                }
<&[u8] as lebe::io::ReadEndian<[u8]>>::read_from_little_endian_into
Line
Count
Source
463
32.2k
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
32.2k
                    unsafe { bytes::read_slice(self, value)? };
465
32.2k
                    value.convert_little_endian_to_current();
466
32.2k
                    Ok(())
467
32.2k
                }
Unexecuted instantiation: <&[u8] as lebe::io::ReadEndian<[u16]>>::read_from_little_endian_into
Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as lebe::io::ReadEndian<[f32]>>::read_from_little_endian_into
Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as lebe::io::ReadEndian<[u16]>>::read_from_little_endian_into
Unexecuted instantiation: <std::io::cursor::Cursor<&[u8]> as lebe::io::ReadEndian<[u32]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[i16]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[i32]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[i64]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[i128]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[f64]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[f32]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[u8]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[u16]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[u32]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[u64]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[u128]>>::read_from_little_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[i8]>>::read_from_little_endian_into
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<[u8]>>::read_from_little_endian_into
Line
Count
Source
463
644k
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
644k
                    unsafe { bytes::read_slice(self, value)? };
465
644k
                    value.convert_little_endian_to_current();
466
644k
                    Ok(())
467
644k
                }
<exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<[u64]>>::read_from_little_endian_into
Line
Count
Source
463
84
                fn read_from_little_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
464
84
                    unsafe { bytes::read_slice(self, value)? };
465
84
                    value.convert_little_endian_to_current();
466
84
                    Ok(())
467
84
                }
Unexecuted instantiation: <exr::io::PeekRead<exr::io::Tracking<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>> as lebe::io::ReadEndian<[i8]>>::read_from_little_endian_into
468
469
0
                fn read_from_big_endian_into(&mut self, value: &mut [$type]) -> Result<()> {
470
0
                    unsafe { bytes::read_slice(self, value)? };
471
0
                    value.convert_big_endian_to_current();
472
0
                    Ok(())
473
0
                }
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[i16]>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[i32]>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[i64]>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[i128]>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[f64]>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[f32]>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[u8]>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[u16]>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[u32]>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[u64]>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[u128]>>::read_from_big_endian_into
Unexecuted instantiation: <_ as lebe::io::ReadEndian<[i8]>>::read_from_big_endian_into
474
            }
475
        };
476
    }
477
478
    call_single_arg_macro_for_each! {
479
        implement_slice_io,
480
        u8, u16, u32, u64, u128,
481
        i8, i16, i32, i64, i128,
482
        f64, f32
483
    }
484
485
486
487
    // TODO: SIMD
488
    /*impl<R: Read> ReadEndian<[f32]> for R {
489
        fn read_from_little_endian_into(&mut self, value: &mut [f32]) -> Result<()> {
490
            unsafe { bytes::read_slice(self, value)? };
491
            value.convert_little_endian_to_current();
492
            Ok(())
493
        }
494
495
        fn read_from_big_endian_into(&mut self, value: &mut [f32]) -> Result<()> {
496
            unsafe { bytes::read_slice(self, value)? };
497
            value.convert_big_endian_to_current();
498
            Ok(())
499
        }
500
    }
501
502
    impl<W: Write> WriteEndian<[f32]> for W {
503
        fn write_as_big_endian(&mut self, value: &[f32]) -> Result<()> {
504
            if cfg!(target_endian = "little") {
505
506
                // FIX ME this SIMD optimization makes no difference ... why? like, ZERO difference, not even worse
507
//                #[cfg(feature = "simd")]
508
                #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
509
                unsafe {
510
                    if is_x86_feature_detected!("avx2") {
511
                        write_bytes_avx(self, value);
512
                        return Ok(());
513
                    }
514
                }
515
516
                // otherwise (no avx2 available)
517
//                for number in value {
518
//                    self.write_as_little_endian(number);
519
//                }
520
//
521
//                return Ok(());
522
                unimplemented!();
523
524
                #[target_feature(enable = "avx2")]
525
                #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
526
                unsafe fn write_bytes_avx(write: &mut impl Write, slice: &[f32]) -> Result<()> {
527
                    #[cfg(target_arch = "x86")] use std::arch::x86 as mm;
528
                    #[cfg(target_arch = "x86_64")] use std::arch::x86_64 as mm;
529
530
                    let bytes: &[u8] = crate::io::bytes::slice_as_bytes(slice);
531
                    let mut chunks = bytes.chunks_exact(32);
532
533
                    let indices = mm::_mm256_set_epi8(
534
                        0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
535
                        0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
536
//                        3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12,
537
//                        3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12
538
                    );
539
540
                    for chunk in &mut chunks {
541
                        let data = mm::_mm256_loadu_si256(chunk.as_ptr() as _);
542
                        let result = mm::_mm256_shuffle_epi8(data, indices);
543
                        let mut out = [0_u8; 32];
544
                        mm::_mm256_storeu_si256(out.as_mut_ptr() as _, result);
545
                        write.write_all(&out)?;
546
                    }
547
548
                    let remainder = chunks.remainder();
549
550
                    { // copy remainder into larger slice, with zeroes at the end
551
                        let mut last_chunk = [0_u8; 32];
552
                        last_chunk[0..remainder.len()].copy_from_slice(remainder);
553
                        let data = mm::_mm256_loadu_si256(last_chunk.as_ptr() as _);
554
                        let result = mm::_mm256_shuffle_epi8(data, indices);
555
                        mm::_mm256_storeu_si256(last_chunk.as_mut_ptr() as _, result);
556
                        write.write_all(&last_chunk[0..remainder.len()])?;
557
                    }
558
559
                    Ok(())
560
                }
561
            }
562
563
            else {
564
                unsafe { bytes::write_slice(self, value)?; }
565
                Ok(())
566
            }
567
        }
568
569
        fn write_as_little_endian(&mut self, value: &[f32]) -> Result<()> {
570
            for number in value {
571
                self.write_as_little_endian(number)?;
572
            }
573
574
            Ok(())
575
        }
576
    }*/
577
}
578