Debian Codegraph @

src/io.rs

raw symbols SCIP
1
2 //! Specialized binary input and output.
3 //! Uses the error handling for this crate.
4
5 #![doc(hidden)]
6 pub use ::stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#};
7
8 use halfrust-analyzer cargo half 2.6.0 crate/::slicerust-analyzer cargo half 2.6.0 slice/::{HalfFloatSliceExtrust-analyzer cargo half 2.6.0 slice/HalfFloatSliceExt#};
9 use leberust-analyzer cargo lebe 0.5.2 crate/::preluderust-analyzer cargo lebe 0.5.2 prelude/::*;
10 use ::halfrust-analyzer cargo half 2.6.0 crate/::f16rust-analyzer cargo half 2.6.0 binary16/f16#;
11 use craterust-analyzer cargo exr 1.74.0 crate/::errorrust-analyzer cargo exr 1.74.0 error/::{Errorrust-analyzer cargo exr 1.74.0 error/Error#, Resultrust-analyzer cargo exr 1.74.0 error/Result#, UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult#, IoResultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#};
12 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#, SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#};
13 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#;
14 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#;
15 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#;
16 use smallvecrust-analyzer cargo smallvec 1.15.1 crate/::{Arrayrust-analyzer cargo smallvec 1.15.1 Array#, SmallVecrust-analyzer cargo smallvec 1.15.1 SmallVec#};
17
18 /// Skip reading uninteresting bytes without allocating.
19 #[inline]
20 pub fn skip_bytesrust-analyzer cargo exr 1.74.0 io/skip_bytes().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, count: usize) -> IoResultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
21 let count = u64::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[u64][`TryFrom<usize>`]try_from().(count).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
22
23 let skipped = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::copyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/copy/copy().(
24 &mut read.by_refrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#by_ref().().takerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#take().(count),
25 &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::sinkrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/util/sink().()
26 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
27
28 // the reader may have ended before we skipped the desired number of bytes
29 if skipped rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]lt().count {
30 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(
31 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::UnexpectedEofrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#UnexpectedEof#,
32 "cannot skip more bytes than exist"
33 ));
34 }
35
36 debug_assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert_eq!!(skipped, count, "skip bytes bug");
37 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
38 }
39
40 /// If an error occurs while writing, attempts to delete the partially written file.
41 /// Creates a file just before the first write operation, not when this function is called.
42 #[inline]
43 pub fn attempt_delete_file_on_write_errorrust-analyzer cargo exr 1.74.0 io/attempt_delete_file_on_write_error().<'p>(path: &'p Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, write: impl FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#(LateFilerust-analyzer cargo exr 1.74.0 io/LateFile#<'p>) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult#) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# {
44 match write(LateFilerust-analyzer cargo exr 1.74.0 io/LateFile#::fromrust-analyzer cargo exr 1.74.0 io/impl#[`LateFile<'p>`][`From<&'p Path>`]from().(path)) {
45 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) => { // FIXME deletes existing file if creation of new file fails?
46 let _deleted = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::remove_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/remove_file().(path); // ignore deletion errors
47 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error)
48 },
49
50 ok => ok,
51 }
52 }
53
54 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
55 pub struct LateFilerust-analyzer cargo exr 1.74.0 io/LateFile#<'p> {
56 pathrust-analyzer cargo exr 1.74.0 io/LateFile#path.: &'p Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#,
57 filerust-analyzer cargo exr 1.74.0 io/LateFile#file.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#>
58 }
59
60 impl<'p> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'p Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#> for LateFilerust-analyzer cargo exr 1.74.0 io/LateFile#<'p> {
61 fn fromrust-analyzer cargo exr 1.74.0 io/impl#[`LateFile<'p>`][`From<&'p Path>`]from().(path: &'p Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#) -> Selfrust-analyzer cargo exr 1.74.0 io/impl#[`LateFile<'p>`][`From<&'p Path>`] { Selfrust-analyzer cargo exr 1.74.0 io/impl#[`LateFile<'p>`][`From<&'p Path>`] { pathrust-analyzer cargo exr 1.74.0 io/LateFile#path., filerust-analyzer cargo exr 1.74.0 io/LateFile#file.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# } }
62 }
63
64 impl<'p> LateFilerust-analyzer cargo exr 1.74.0 io/LateFile#<'p> {
65 fn filerust-analyzer cargo exr 1.74.0 io/impl#[`LateFile<'p>`]file().(&mut self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<&mut Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#> {
66 if self.filerust-analyzer cargo exr 1.74.0 io/LateFile#file..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() { self.filerust-analyzer cargo exr 1.74.0 io/LateFile#file. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(self.pathrust-analyzer cargo exr 1.74.0 io/LateFile#path.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().); }
67 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.filerust-analyzer cargo exr 1.74.0 io/LateFile#file..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()) // will not be reached if creation fails
68 }
69 }
70
71 impl<'p> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write# for LateFilerust-analyzer cargo exr 1.74.0 io/LateFile#<'p> {
72 fn writerust-analyzer cargo exr 1.74.0 io/impl#[`LateFile<'p>`][Write]write().(&mut self, buffer: &[u8]) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> {
73 self.filerust-analyzer cargo exr 1.74.0 io/impl#[`LateFile<'p>`]file().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File][Write]write().(buffer)
74 }
75
76 fn flushrust-analyzer cargo exr 1.74.0 io/impl#[`LateFile<'p>`][Write]flush().(&mut self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
77 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(file) = &mut self.filerust-analyzer cargo exr 1.74.0 io/LateFile#file. { file.flushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File][Write]flush().() }
78 else { Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) }
79 }
80 }
81
82 impl<'p> Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek# for LateFilerust-analyzer cargo exr 1.74.0 io/LateFile#<'p> {
83 fn seekrust-analyzer cargo exr 1.74.0 io/impl#[`LateFile<'p>`][Seek]seek().(&mut self, position: SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<u64> {
84 self.filerust-analyzer cargo exr 1.74.0 io/impl#[`LateFile<'p>`]file().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File][Seek]seek().(position)
85 }
86 }
87
88
89 /// Peek a single byte without consuming it.
90 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
91 pub struct PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#<T> {
92
93 /// Cannot be exposed as it will not contain peeked values anymore.
94 innerrust-analyzer cargo exr 1.74.0 io/PeekRead#inner.: T,
95
96 peekedrust-analyzer cargo exr 1.74.0 io/PeekRead#peeked.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<IoResultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<u8>>,
97 }
98
99 impl<T: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#<T> {
100
101 /// Wrap a reader to make it peekable.
102 #[inline]
103 pub fn newrust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]new().(inner: T) -> Selfrust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`] {
104 Selfrust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`] { innerrust-analyzer cargo exr 1.74.0 io/PeekRead#inner., peekedrust-analyzer cargo exr 1.74.0 io/PeekRead#peeked.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# }
105 }
106
107 /// Read a single byte and return that without consuming it.
108 /// The next `read` call will include that byte.
109 #[inline]
110 pub fn peek_u8rust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]peek_u8().(&mut self) -> &IoResultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<u8> {
111 self.peekedrust-analyzer cargo exr 1.74.0 io/PeekRead#peeked. = self.peekedrust-analyzer cargo exr 1.74.0 io/PeekRead#peeked..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().().or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]or_else().(|| Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(u8::read_from_little_endianrust-analyzer cargo lebe 0.5.2 io/ReadPrimitive#read_from_little_endian().(&mut self.innerrust-analyzer cargo exr 1.74.0 io/PeekRead#inner.)));
112 self.peekedrust-analyzer cargo exr 1.74.0 io/PeekRead#peeked..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() // unwrap cannot fail because we just set it
113 }
114
115 /// Skip a single byte if it equals the specified value.
116 /// Returns whether the value was found.
117 /// Consumes the peeked result if an error occurred.
118 #[inline]
119 pub fn skip_if_eqrust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]skip_if_eq().(&mut self, value: u8) -> IoResultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<bool> {
120 match self.peek_u8rust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]peek_u8().() {
121 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(peeked) if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().peeked rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().value => {
122 self.peekedrust-analyzer cargo exr 1.74.0 io/PeekRead#peeked. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; // consume the byte
123 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true)
124 },
125
126 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(_) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(false),
127
128 // return the error otherwise.
129 // unwrap is safe because this branch cannot be reached otherwise.
130 // we need to take() from self because io errors cannot be cloned.
131 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(self.peekedrust-analyzer cargo exr 1.74.0 io/PeekRead#peeked..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]err().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().())
132 }
133 }
134 }
135
136
137 impl<T: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#<T> {
138 fn readrust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`][Read]read().(&mut self, target_buffer: &mut [u8]) -> IoResultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> {
139 if target_buffer.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
140 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0)
141 }
142
143 match self.peekedrust-analyzer cargo exr 1.74.0 io/PeekRead#peeked..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() {
144 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => self.innerrust-analyzer cargo exr 1.74.0 io/PeekRead#inner..readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(target_buffer),
145 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(peeked) => {
146 target_buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = peeked?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
147
148 // indexing [1..] is safe because an empty buffer already returned ok
149 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().self.innerrust-analyzer cargo exr 1.74.0 io/PeekRead#inner..readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(&mut target_buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
150 }
151 }
152 }
153 }
154
155 impl<T: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#> PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#<Trackingrust-analyzer cargo exr 1.74.0 io/Tracking#<T>> {
156
157 /// Seek this read to the specified byte position.
158 /// Discards any previously peeked value.
159 pub fn skip_torust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<Tracking<T>>`]skip_to().(&mut self, position: usize) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
160 self.innerrust-analyzer cargo exr 1.74.0 io/PeekRead#inner..seek_read_torust-analyzer cargo exr 1.74.0 io/impl#[`Tracking<T>`]seek_read_to().(position)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
161 self.peekedrust-analyzer cargo exr 1.74.0 io/PeekRead#peeked. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
162 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
163 }
164 }
165
166 impl<T: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#<Trackingrust-analyzer cargo exr 1.74.0 io/Tracking#<T>> {
167
168 /// Current number of bytes read.
169 pub fn byte_positionrust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<Tracking<T>>`]byte_position().(&self) -> usize {
170 self.innerrust-analyzer cargo exr 1.74.0 io/PeekRead#inner..byte_positionrust-analyzer cargo exr 1.74.0 io/impl#[`Tracking<T>`]byte_position().()
171 }
172 }
173
174 /// Keep track of what byte we are at.
175 /// Used to skip back to a previous place after writing some information.
176 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
177 pub struct Trackingrust-analyzer cargo exr 1.74.0 io/Tracking#<T> {
178
179 /// Do not expose to prevent seeking without updating position
180 innerrust-analyzer cargo exr 1.74.0 io/Tracking#inner.: T,
181
182 positionrust-analyzer cargo exr 1.74.0 io/Tracking#position.: usize,
183 }
184
185 impl<T: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for Trackingrust-analyzer cargo exr 1.74.0 io/Tracking#<T> {
186 fn readrust-analyzer cargo exr 1.74.0 io/impl#[`Tracking<T>`][Read]read().(&mut self, buffer: &mut [u8]) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> {
187 let count = self.innerrust-analyzer cargo exr 1.74.0 io/Tracking#inner..readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(buffer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
188 self.positionrust-analyzer cargo exr 1.74.0 io/Tracking#position. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().count;
189 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(count)
190 }
191 }
192
193 impl<T: Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#> Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write# for Trackingrust-analyzer cargo exr 1.74.0 io/Tracking#<T> {
194 fn writerust-analyzer cargo exr 1.74.0 io/impl#[`Tracking<T>`][Write]write().(&mut self, buffer: &[u8]) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> {
195 let count = self.innerrust-analyzer cargo exr 1.74.0 io/Tracking#inner..writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write().(buffer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
196 self.positionrust-analyzer cargo exr 1.74.0 io/Tracking#position. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().count;
197 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(count)
198 }
199
200 fn flushrust-analyzer cargo exr 1.74.0 io/impl#[`Tracking<T>`][Write]flush().(&mut self) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
201 self.innerrust-analyzer cargo exr 1.74.0 io/Tracking#inner..flushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#flush().()
202 }
203 }
204
205 impl<T> Trackingrust-analyzer cargo exr 1.74.0 io/Tracking#<T> {
206
207 /// If `inner` is a reference, if must never be seeked directly,
208 /// but only through this `Tracking` instance.
209 pub fn newrust-analyzer cargo exr 1.74.0 io/impl#[`Tracking<T>`]new().(inner: T) -> Selfrust-analyzer cargo exr 1.74.0 io/impl#[`Tracking<T>`] {
210 Trackingrust-analyzer cargo exr 1.74.0 io/Tracking# { innerrust-analyzer cargo exr 1.74.0 io/Tracking#inner., positionrust-analyzer cargo exr 1.74.0 io/Tracking#position.: 0 }
211 }
212
213 /// Current number of bytes written or read.
214 pub fn byte_positionrust-analyzer cargo exr 1.74.0 io/impl#[`Tracking<T>`]byte_position().(&self) -> usize {
215 self.positionrust-analyzer cargo exr 1.74.0 io/Tracking#position.
216 }
217 }
218
219 impl<T: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#> Trackingrust-analyzer cargo exr 1.74.0 io/Tracking#<T> {
220
221 /// Set the reader to the specified byte position.
222 /// If it is only a couple of bytes, no seek system call is performed.
223 pub fn seek_read_torust-analyzer cargo exr 1.74.0 io/impl#[`Tracking<T>`]seek_read_to().(&mut self, target_position: usize) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
224 let delta = target_position as i128 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i128][`Sub<Self>`]sub().self.positionrust-analyzer cargo exr 1.74.0 io/Tracking#position. as i128; // FIXME panicked at 'attempt to subtract with overflow'
225 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(delta.absrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i128]abs().() <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]lt(). usize::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]MAX. as i128);
226
227 if delta rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]gt().0 && delta rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialOrd<Self>`]lt().16 { // TODO profile that this is indeed faster than a syscall! (should be because of bufread buffer discard)
228 skip_bytesrust-analyzer cargo exr 1.74.0 io/skip_bytes().(self, delta as usize)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
229 self.positionrust-analyzer cargo exr 1.74.0 io/Tracking#position. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().delta as usize;
230 }
231 else if delta rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i128][`PartialEq<Self>`]ne().0 {
232 self.innerrust-analyzer cargo exr 1.74.0 io/Tracking#inner..seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(u64::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[u64][`TryFrom<usize>`]try_from().(target_position).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
233 self.positionrust-analyzer cargo exr 1.74.0 io/Tracking#position. = target_position;
234 }
235
236 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
237 }
238 }
239
240 impl<T: Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#> Trackingrust-analyzer cargo exr 1.74.0 io/Tracking#<T> {
241
242 /// Move the writing cursor to the specified target byte index.
243 /// If seeking forward, this will write zeroes.
244 pub fn seek_write_torust-analyzer cargo exr 1.74.0 io/impl#[`Tracking<T>`]seek_write_to().(&mut self, target_position: usize) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
245 if target_position rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.positionrust-analyzer cargo exr 1.74.0 io/Tracking#position. {
246 self.innerrust-analyzer cargo exr 1.74.0 io/Tracking#inner..seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(u64::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[u64][`TryFrom<usize>`]try_from().(target_position).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
247 }
248 else if target_position rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().self.positionrust-analyzer cargo exr 1.74.0 io/Tracking#position. {
249 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::copyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/copy/copy().(
250 &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::repeatrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/util/repeat().(0).takerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#take().(u64::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[u64][`TryFrom<usize>`]try_from().(target_position rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().self.positionrust-analyzer cargo exr 1.74.0 io/Tracking#position.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()),
251 self
252 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
253 }
254
255 self.positionrust-analyzer cargo exr 1.74.0 io/Tracking#position. = target_position;
256 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
257 }
258 }
259
260
261 /// Generic trait that defines common binary operations such as reading and writing for this type.
262 pub trait Datarust-analyzer cargo exr 1.74.0 io/Data#: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# {
263
264 /// Number of bytes this would consume in an exr file.
265 const BYTE_SIZErust-analyzer cargo exr 1.74.0 io/Data#BYTE_SIZE.: usize = ::stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<Self>();
266
267 /// Read a value of type `Self` from a little-endian source.
268 fn read_lerust-analyzer cargo exr 1.74.0 io/Data#read_le().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Self>;
269
270 /// Read a value of type `Self` from a **native-endian** source (no conversion).
271 fn read_nerust-analyzer cargo exr 1.74.0 io/Data#read_ne().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Self>;
272
273 /// Read as many values of type `Self` as fit into the specified slice, from a little-endian source.
274 /// If the slice cannot be filled completely, returns `Error::Invalid`.
275 fn read_slice_lerust-analyzer cargo exr 1.74.0 io/Data#read_slice_le().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, slice: &mut[Self]) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult#;
276
277 /// Read as many values of type `Self` as fit into the specified slice, from a **native-endian** source (no conversion).
278 /// If the slice cannot be filled completely, returns `Error::Invalid`.
279 fn read_slice_nerust-analyzer cargo exr 1.74.0 io/Data#read_slice_ne().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, slice: &mut[Self]) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult#;
280
281 /// Read as many values of type `Self` as specified with `data_size`.
282 ///
283 /// This method will not allocate more memory than `soft_max` at once.
284 /// If `hard_max` is specified, it will never read any more than that.
285 /// Returns `Error::Invalid` if the reader does not contain the desired number of elements.
286 /// Reads from little-endian byte source.
287 #[inline]
288 fn read_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_vec_le().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, data_size: usize, soft_max: usize, hard_max: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, purpose: &'static str)
289 -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Self>>
290 {
291 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(max) = hard_max {
292 if data_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().max {
293 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().(purpose))
294 }
295 }
296
297 let mut vec = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(data_size.minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(soft_max));
298 Self::read_into_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_into_vec_le().(read, &mut vec, data_size, soft_max, hard_max, purpose)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
299 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(vec)
300 }
301
302 /// Write this value to the writer, converting to little-endian format.
303 fn write_lerust-analyzer cargo exr 1.74.0 io/Data#write_le().(self, write: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult#;
304
305 /// Write this value to the writer, in **native-endian** format (no conversion).
306 fn write_nerust-analyzer cargo exr 1.74.0 io/Data#write_ne().(self, write: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult#;
307
308 /// Write all values of that slice to the writer, converting to little-endian format.
309 fn write_slice_lerust-analyzer cargo exr 1.74.0 io/Data#write_slice_le().(write: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, slice: &[Self]) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult#;
310
311 /// Write all values of that slice to the writer, in **native-endian** format (no conversion).
312 fn write_slice_nerust-analyzer cargo exr 1.74.0 io/Data#write_slice_ne().(write: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, slice: &[Self]) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult#;
313
314
315 /// Read as many values of type `Self` as specified with `data_size` into the provided vector.
316 ///
317 /// This method will not allocate more memory than `soft_max` at once.
318 /// If `hard_max` is specified, it will never read any more than that.
319 /// Returns `Error::Invalid` if reader does not contain the desired number of elements.
320 #[inline]
321 fn read_into_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_into_vec_le().(
322 read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#,
323 data: &mut impl ResizableVecrust-analyzer cargo exr 1.74.0 io/ResizableVec#<Self>,
324 data_size: usize, soft_max: usize, hard_max: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>,
325 purpose: &'static str
326 ) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# {
327 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(max) = hard_max {
328 if data_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().max {
329 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().(purpose))
330 }
331 }
332
333 let soft_max = hard_max.unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(soft_max).minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(soft_max);
334 let end = data.lenrust-analyzer cargo exr 1.74.0 io/ResizableVec#len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().data_size;
335
336 // do not allocate more than $chunks memory at once
337 // (most of the time, this loop will run only once)
338 while data.lenrust-analyzer cargo exr 1.74.0 io/ResizableVec#len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().end {
339 let chunk_start = data.lenrust-analyzer cargo exr 1.74.0 io/ResizableVec#len().();
340 let chunk_end = (chunk_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().soft_max).minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(data_size);
341
342 data.resizerust-analyzer cargo exr 1.74.0 io/ResizableVec#resize().(chunk_end, Self::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().());
343 Self::read_slice_lerust-analyzer cargo exr 1.74.0 io/Data#read_slice_le().(read, &mut data.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#as_mut().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().chunk_start rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range# rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#chunk_end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; // safe because of `min(data_size)`
344 }
345
346 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
347 }
348
349 /// Write the length of the slice and then its contents, converting to little-endian format.
350 #[inline]
351 fn write_i32_sized_slice_lerust-analyzer cargo exr 1.74.0 io/Data#write_i32_sized_slice_le().<W: Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#>(write: &mut W, slice: &[Self]) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# {
352 i32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[i32][`TryFrom<usize>`]try_from().(slice.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..write_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]write_le().(write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
353 Self::write_slice_lerust-analyzer cargo exr 1.74.0 io/Data#write_slice_le().(write, slice)
354 }
355
356 /// Read the desired element count and then read that many items into a vector.
357 ///
358 /// This method will not allocate more memory than `soft_max` at once.
359 /// If `hard_max` is specified, it will never read any more than that.
360 /// Returns `Error::Invalid` if reader does not contain the desired number of elements.
361 #[inline]
362 fn read_i32_sized_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_i32_sized_vec_le().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, soft_max: usize, hard_max: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, purpose: &'static str) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Self>> {
363 let size = usize::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[usize][`TryFrom<i32>`]try_from().(i32::read_lerust-analyzer cargo exr 1.74.0 io/impl#[i32][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
364 Self::read_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_vec_le().(read, size, soft_max, hard_max, purpose)
365 }
366
367 /// Fill the slice with this value.
368 #[inline]
369 fn fill_slicerust-analyzer cargo exr 1.74.0 io/Data#fill_slice().(self, slice: &mut [Self]) where Self: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# {
370 // hopefully compiles down to a single memset call
371 for value in slice {
372 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().value = self;
373 }
374 }
375 }
376
377 /// A unifying trait that is implemented for Vec and SmallVec,
378 /// focused on resizing capabilities.
379 pub trait ResizableVecrust-analyzer cargo exr 1.74.0 io/ResizableVec#<T>: AsMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#<[T]> {
380 fn resizerust-analyzer cargo exr 1.74.0 io/ResizableVec#resize().(&mut self, new_len: usize, value: T);
381 fn lenrust-analyzer cargo exr 1.74.0 io/ResizableVec#len().(&self) -> usize;
382 }
383
384 impl<T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#> ResizableVecrust-analyzer cargo exr 1.74.0 io/ResizableVec#<T> for Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T> {
385 fn resizerust-analyzer cargo exr 1.74.0 io/impl#[`Vec<T>`][`ResizableVec<T>`]resize().(&mut self, new_len: usize, value: T) {
386 Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::resizerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]resize().(self, new_len, value)
387 }
388 fn lenrust-analyzer cargo exr 1.74.0 io/impl#[`Vec<T>`][`ResizableVec<T>`]len().(&self) -> usize {
389 Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(self)
390 }
391 }
392
393 impl<T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#, A: Arrayrust-analyzer cargo smallvec 1.15.1 Array#<Itemrust-analyzer cargo smallvec 1.15.1 Array#Item#=T>> ResizableVecrust-analyzer cargo exr 1.74.0 io/ResizableVec#<T> for SmallVecrust-analyzer cargo smallvec 1.15.1 SmallVec#<A> {
394 fn resizerust-analyzer cargo exr 1.74.0 io/impl#[`SmallVec<A>`][`ResizableVec<T>`]resize().(&mut self, new_len: usize, value: T) {
395 SmallVecrust-analyzer cargo smallvec 1.15.1 SmallVec#::resizerust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]resize().(self, new_len, value)
396 }
397 fn lenrust-analyzer cargo exr 1.74.0 io/impl#[`SmallVec<A>`][`ResizableVec<T>`]len().(&self) -> usize {
398 SmallVecrust-analyzer cargo smallvec 1.15.1 SmallVec#::lenrust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]len().(self)
399 }
400 }
401
402
403
404 macro_rules! implement_data_for_primitiverust-analyzer cargo exr 1.74.0 io/implement_data_for_primitive! {
405 ($kind: ident) => {
406 impl Data for $kind {
407 #[inline]
408 fn read_le(read: &mut impl Read) -> Result<Self> {
409 Ok(read.read_from_little_endian()?)
410 }
411
412 #[inline]
413 fn read_ne(read: &mut impl Read) -> Result<Self> {
414 Ok(read.read_from_native_endian()?)
415 }
416
417 #[inline]
418 fn write_le(self, write: &mut impl Write) -> Result<()> {
419 write.write_as_little_endian(&self)?;
420 Ok(())
421 }
422
423 #[inline]
424 fn write_ne(self, write: &mut impl Write) -> Result<()> {
425 write.write_as_native_endian(&self)?;
426 Ok(())
427 }
428
429 #[inline]
430 fn read_slice_le(read: &mut impl Read, slice: &mut [Self]) -> Result<()> {
431 read.read_from_little_endian_into(slice)?;
432 Ok(())
433 }
434
435 #[inline]
436 fn read_slice_ne(read: &mut impl Read, slice: &mut [Self]) -> Result<()> {
437 read.read_from_native_endian_into(slice)?;
438 Ok(())
439 }
440
441 #[inline]
442 fn write_slice_le(write: &mut impl Write, slice: &[Self]) -> Result<()> {
443 write.write_as_little_endian(slice)?;
444 Ok(())
445 }
446
447 #[inline]
448 fn write_slice_ne(write: &mut impl Write, slice: &[Self]) -> Result<()> {
449 write.write_as_native_endian(slice)?;
450 Ok(())
451 }
452 }
453 };
454 }
455
456 implement_data_for_primitiverust-analyzer cargo exr 1.74.0 io/implement_data_for_primitive!!(u8);
457 implement_data_for_primitiverust-analyzer cargo exr 1.74.0 io/implement_data_for_primitive!!(i8);
458 implement_data_for_primitiverust-analyzer cargo exr 1.74.0 io/implement_data_for_primitive!!(i16);
459 implement_data_for_primitiverust-analyzer cargo exr 1.74.0 io/implement_data_for_primitive!!(u16);
460 implement_data_for_primitiverust-analyzer cargo exr 1.74.0 io/implement_data_for_primitive!!(u32);
461 implement_data_for_primitiverust-analyzer cargo exr 1.74.0 io/implement_data_for_primitive!!(i32);
462 implement_data_for_primitiverust-analyzer cargo exr 1.74.0 io/implement_data_for_primitive!!(i64);
463 implement_data_for_primitiverust-analyzer cargo exr 1.74.0 io/implement_data_for_primitive!!(u64);
464 implement_data_for_primitiverust-analyzer cargo exr 1.74.0 io/implement_data_for_primitive!!(f32);
465 implement_data_for_primitiverust-analyzer cargo exr 1.74.0 io/implement_data_for_primitive!!(f64);
466
467
468 impl Datarust-analyzer cargo exr 1.74.0 io/Data# for f16rust-analyzer cargo half 2.6.0 binary16/f16# {
469 #[inline]
470 fn read_lerust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]read_le().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]> {
471 u16::read_lerust-analyzer cargo exr 1.74.0 io/impl#[u16][Data]read_le().(read).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(f16rust-analyzer cargo half 2.6.0 binary16/f16#::from_bitsrust-analyzer cargo half 2.6.0 binary16/impl#[f16]from_bits().)
472 }
473
474 #[inline]
475 fn read_nerust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]read_ne().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]> {
476 u16::read_nerust-analyzer cargo exr 1.74.0 io/impl#[u16][Data]read_ne().(read).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(f16rust-analyzer cargo half 2.6.0 binary16/f16#::from_bitsrust-analyzer cargo half 2.6.0 binary16/impl#[f16]from_bits().)
477 }
478
479 #[inline]
480 fn read_slice_lerust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]read_slice_le().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, slice: &mut [Selfrust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]]) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<()> {
481 let bits_mut = slice.reinterpret_cast_mutrust-analyzer cargo half 2.6.0 slice/impl#[`[f16]`][HalfFloatSliceExt]reinterpret_cast_mut().();
482 u16::read_slice_lerust-analyzer cargo exr 1.74.0 io/impl#[u16][Data]read_slice_le().(read, bits_mut)
483 }
484
485 #[inline]
486 fn read_slice_nerust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]read_slice_ne().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, slice: &mut [Selfrust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]]) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<()> {
487 let bits_mut = slice.reinterpret_cast_mutrust-analyzer cargo half 2.6.0 slice/impl#[`[f16]`][HalfFloatSliceExt]reinterpret_cast_mut().();
488 u16::read_slice_nerust-analyzer cargo exr 1.74.0 io/impl#[u16][Data]read_slice_ne().(read, bits_mut)
489 }
490
491 #[inline]
492 fn write_lerust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]write_le().(self, write: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<()> {
493 self.to_bitsrust-analyzer cargo half 2.6.0 binary16/impl#[f16]to_bits().().write_lerust-analyzer cargo exr 1.74.0 io/impl#[u16][Data]write_le().(write)
494 }
495
496 #[inline]
497 fn write_nerust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]write_ne().(self, write: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<()> {
498 self.to_bitsrust-analyzer cargo half 2.6.0 binary16/impl#[f16]to_bits().().write_nerust-analyzer cargo exr 1.74.0 io/impl#[u16][Data]write_ne().(write)
499 }
500
501 #[inline]
502 fn write_slice_lerust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]write_slice_le().(write: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, slice: &[Selfrust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]]) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<()> {
503 let bits = slice.reinterpret_castrust-analyzer cargo half 2.6.0 slice/impl#[`[f16]`][HalfFloatSliceExt]reinterpret_cast().();
504 u16::write_slice_lerust-analyzer cargo exr 1.74.0 io/impl#[u16][Data]write_slice_le().(write, bits)
505 }
506
507 #[inline]
508 fn write_slice_nerust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]write_slice_ne().(write: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, slice: &[Selfrust-analyzer cargo exr 1.74.0 io/impl#[f16][Data]]) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<()> {
509 let bits = slice.reinterpret_castrust-analyzer cargo half 2.6.0 slice/impl#[`[f16]`][HalfFloatSliceExt]reinterpret_cast().();
510 u16::write_slice_nerust-analyzer cargo exr 1.74.0 io/impl#[u16][Data]write_slice_ne().(write, bits)
511 }
512 }
513
514
515 #[cfg(test)]
516 mod testrust-analyzer cargo exr 1.74.0 io/test/ {
517 use craterust-analyzer cargo exr 1.74.0 crate/::iorust-analyzer cargo exr 1.74.0 io/::PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#;
518 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#;
519
520 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
521 fn peekrust-analyzer cargo exr 1.74.0 io/test/peek().(){
522 use leberust-analyzer cargo lebe 0.5.2 crate/::preluderust-analyzer cargo lebe 0.5.2 prelude/::*;
523 let buffer: &[u8] = &[0,1,2,3];
524 let mut peek = PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#::newrust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]new().(buffer);
525
526 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(peek.peek_u8rust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]peek_u8().().as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), &0);
527 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(peek.peek_u8rust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]peek_u8().().as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), &0);
528 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(peek.peek_u8rust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]peek_u8().().as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), &0);
529 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(u8::read_from_little_endianrust-analyzer cargo lebe 0.5.2 io/ReadPrimitive#read_from_little_endian().(&mut peek).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 0_u8);
530
531 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(peek.readrust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`][Read]read().(&mut [0,0]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 2);
532
533 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(peek.peek_u8rust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]peek_u8().().as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), &3);
534 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(u8::read_from_little_endianrust-analyzer cargo lebe 0.5.2 io/ReadPrimitive#read_from_little_endian().(&mut peek).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), 3_u8);
535
536 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(peek.peek_u8rust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]peek_u8().().is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
537 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(peek.peek_u8rust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]peek_u8().().is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
538 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(peek.peek_u8rust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]peek_u8().().is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
539 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(peek.peek_u8rust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]peek_u8().().is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
540
541 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(u8::read_from_little_endianrust-analyzer cargo lebe 0.5.2 io/ReadPrimitive#read_from_little_endian().(&mut peek).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
542 }
543 }
544
545