Debian Codegraph @

src/read.rs

raw symbols SCIP
1 #[cfg(feature = "alloc")]
2 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::{vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#};
3 #[cfg(feature = "std")]
4 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/;
5 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/;
6
7 #[cfg(feature = "std")]
8 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/::{selfrust-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# as StdReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#};
9
10 use craterust-analyzer cargo serde_cbor_2 0.13.0 crate/::errorrust-analyzer cargo serde_cbor_2 0.13.0 error/::{Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#, ErrorCoderust-analyzer cargo serde_cbor_2 0.13.0 error/ErrorCode#, Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#};
11
12 #[cfg(not(feature = "unsealed_read_write"))]
13 /// Trait used by the deserializer for iterating over input.
14 ///
15 /// This trait is sealed by default, enabling the `unsealed_read_write` feature removes this bound
16 /// to allow objects outside of this crate to implement this trait.
17 pub trait Read<'de>: private::Sealed {
18 #[doc(hidden)]
19 /// Read n bytes from the input.
20 ///
21 /// Implementations that can are asked to return a slice with a Long lifetime that outlives the
22 /// decoder, but others (eg. ones that need to allocate the data into a temporary buffer) can
23 /// return it with a Short lifetime that just lives for the time of read's mutable borrow of
24 /// the reader.
25 ///
26 /// This may, as a side effect, clear the reader's scratch buffer (as the provided
27 /// implementation does).
28 ///
29 /// A more appropriate lifetime setup for this (that would allow the Deserializer::convert_str
30 /// to stay a function) would be something like `fn read<'a, 'r: 'a>(&'a mut 'r immut self, ...) -> ...
31 /// EitherLifetime<'r, 'de>>`, which borrows self mutably for the duration of the function and
32 /// downgrates that reference to an immutable one that outlives the result (protecting the
33 /// scratch buffer from changes), but alas, that can't be expressed (yet?).
34 fn read<'a>(&'a mut self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#<'a, 'de>> {
35 selfrust-analyzer cargo serde_cbor_2 0.13.0 read/.clear_buffer();
36 selfrust-analyzer cargo serde_cbor_2 0.13.0 read/.read_to_buffer(n)?;
37
38 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(selfrust-analyzer cargo serde_cbor_2 0.13.0 read/.take_buffer())
39 }
40
41 #[doc(hidden)]
42 fn next(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>>;
43
44 #[doc(hidden)]
45 fn peek(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>>;
46
47 #[doc(hidden)]
48 fn clear_buffer(&mut self);
49
50 #[doc(hidden)]
51 fn read_to_buffer(&mut self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()>;
52
53 #[doc(hidden)]
54 fn take_buffer<'a>(&'a mut self) -> EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#<'a, 'de>;
55
56 #[doc(hidden)]
57 fn read_into(&mut self, buf: &mut [u8]) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()>;
58
59 #[doc(hidden)]
60 fn discard(&mut self);
61
62 #[doc(hidden)]
63 fn offset(&self) -> u64;
64 }
65
66 #[cfg(feature = "unsealed_read_write")]
67 /// Trait used by the deserializer for iterating over input.
68 pub trait Readrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#<'de> {
69 /// Read n bytes from the input.
70 ///
71 /// Implementations that can are asked to return a slice with a Long lifetime that outlives the
72 /// decoder, but others (eg. ones that need to allocate the data into a temporary buffer) can
73 /// return it with a Short lifetime that just lives for the time of read's mutable borrow of
74 /// the reader.
75 ///
76 /// This may, as a side effect, clear the reader's scratch buffer (as the provided
77 /// implementation does).
78
79 // A more appropriate lifetime setup for this (that would allow the Deserializer::convert_str
80 // to stay a function) would be something like `fn read<'a, 'r: 'a>(&'a mut 'r immut self, ...) -> ...
81 // EitherLifetime<'r, 'de>>`, which borrows self mutably for the duration of the function and
82 // downgrates that reference to an immutable one that outlives the result (protecting the
83 // scratch buffer from changes), but alas, that can't be expressed (yet?).
84 fn readrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#read().<'a>(&'a mut self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#<'a, 'de>> {
85 self.clear_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#clear_buffer().();
86 self.read_to_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#read_to_buffer().(n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
87
88 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.take_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#take_buffer().())
89 }
90
91 /// Read the next byte from the input, if any.
92 fn nextrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#next().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>>;
93
94 /// Peek at the next byte of the input, if any. This does not advance the reader, so the result
95 /// of this function will remain the same until a read or clear occurs.
96 fn peekrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#peek().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>>;
97
98 /// Clear the underlying scratch buffer
99 fn clear_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#clear_buffer().(&mut self);
100
101 /// Append n bytes from the reader to the reader's scratch buffer (without clearing it)
102 fn read_to_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#read_to_buffer().(&mut self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()>;
103
104 /// Read out everything accumulated in the reader's scratch buffer. This may, as a side effect,
105 /// clear it.
106 fn take_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#take_buffer().<'a>(&'a mut self) -> EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#<'a, 'de>;
107
108 /// Read from the input until `buf` is full or end of input is encountered.
109 fn read_intorust-analyzer cargo serde_cbor_2 0.13.0 read/Read#read_into().(&mut self, buf: &mut [u8]) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()>;
110
111 /// Discard any data read by `peek`.
112 fn discardrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#discard().(&mut self);
113
114 /// Returns the offset from the start of the reader.
115 fn offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#offset().(&self) -> u64;
116 }
117
118 /// Represents a reader that can return its current position
119 pub trait Offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/Offset# {
120 fn byte_offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/Offset#byte_offset().(&self) -> usize;
121 }
122
123 /// Represents a buffer with one of two lifetimes.
124 pub enum EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#<'short, 'long> {
125 /// The short lifetime
126 Shortrust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#Short#(&'short [u8]),
127 /// The long lifetime
128 Longrust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#Long#(&'long [u8]),
129 }
130
131 #[cfg(not(feature = "unsealed_read_write"))]
132 mod private {
133 pub trait Sealed {}
134 }
135
136 /// CBOR input source that reads from a std::io input stream.
137 #[cfg(feature = "std")]
138 #[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:)]
139 pub struct IoReadrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#<R>
140 where
141 R: 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#,
142 {
143 readerrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#reader.: OffsetReaderrust-analyzer cargo serde_cbor_2 0.13.0 read/OffsetReader#<R>,
144 scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#scratch.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>,
145 chrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#ch.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>,
146 }
147
148 #[cfg(feature = "std")]
149 impl<R> IoReadrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#<R>
150 where
151 R: 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#,
152 {
153 /// Creates a new CBOR input source to read from a std::io input stream.
154 pub fn newrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`]new().(reader: R) -> IoReadrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#<R> {
155 IoReadrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead# {
156 readerrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#reader.: OffsetReaderrust-analyzer cargo serde_cbor_2 0.13.0 read/OffsetReader# { readerrust-analyzer cargo serde_cbor_2 0.13.0 read/OffsetReader#reader., offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/OffsetReader#offset.: 0 },
157 scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#scratch.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![],
158 chrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#ch.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
159 }
160 }
161
162 #[inline]
163 fn next_innerrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`]next_inner().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>> {
164 let mut buf = [0; 1];
165 loop {
166 match self.readerrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#reader..readrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`OffsetReader<R>`][Read]read().(&mut buf) {
167 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0) => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#),
168 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(_) => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().)),
169 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ref e) if e.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().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#::Interruptedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Interrupted# => {}
170 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::iorust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]io().(e)),
171 }
172 }
173 }
174 }
175
176 #[cfg(all(feature = "std", not(feature = "unsealed_read_write")))]
177 impl<R> private::Sealed for IoReadrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#<R> where R: 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# {}
178
179 #[cfg(feature = "std")]
180 impl<'de, R> Readrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#<'de> for IoReadrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#<R>
181 where
182 R: 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#,
183 {
184 #[inline]
185 fn nextrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][`Read<'de>`]next().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>> {
186 match self.chrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#ch..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() {
187 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ch) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ch)),
188 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => self.next_innerrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`]next_inner().(),
189 }
190 }
191
192 #[inline]
193 fn peekrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][`Read<'de>`]peek().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>> {
194 match self.chrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#ch. {
195 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ch) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ch)),
196 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => {
197 self.chrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#ch. = self.next_innerrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`]next_inner().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
198 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.chrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#ch.)
199 }
200 }
201 }
202
203 fn read_to_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][`Read<'de>`]read_to_buffer().(&mut self, mut n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> {
204 // defend against malicious input pretending to be huge strings by limiting growth
205 self.scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#scratch..reserverust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]reserve().(cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(n, 16 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().1024));
206
207 if n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
208 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(());
209 }
210
211 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ch) = self.chrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#ch..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() {
212 self.scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#scratch..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ch);
213 n rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1;
214 }
215
216 // n == 0 is OK here and needs no further special treatment
217
218 let transfer_result = {
219 // Prepare for take() (which consumes its reader) by creating a reference adaptor
220 // that'll only live in this block
221 let reference = self.readerrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#reader..by_refrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#by_ref().();
222 // Append the first n bytes of the reader to the scratch vector (or up to
223 // an error or EOF indicated by a shorter read)
224 let mut taken = reference.takerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#take().(n as u64);
225 taken.read_to_endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_to_end().(&mut self.scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#scratch.)
226 };
227
228 match transfer_result {
229 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(r) if r rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().n => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()),
230 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(_) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]syntax().(
231 ErrorCoderust-analyzer cargo serde_cbor_2 0.13.0 error/ErrorCode#::EofWhileParsingValuerust-analyzer cargo serde_cbor_2 0.13.0 error/ErrorCode#EofWhileParsingValue#,
232 self.offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][`Read<'de>`]offset().(),
233 )),
234 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::iorust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]io().(e)),
235 }
236 }
237
238 fn clear_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][`Read<'de>`]clear_buffer().(&mut self) {
239 self.scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#scratch..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().();
240 }
241
242 fn take_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][`Read<'de>`]take_buffer().<'a>(&'a mut self) -> EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#<'a, 'de> {
243 EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#::Shortrust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#Short#(&self.scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#scratch.)
244 }
245
246 fn read_intorust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][`Read<'de>`]read_into().(&mut self, buf: &mut [u8]) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> {
247 self.readerrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#reader..read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(buf).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| {
248 if e.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().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# {
249 Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]syntax().(ErrorCoderust-analyzer cargo serde_cbor_2 0.13.0 error/ErrorCode#::EofWhileParsingValuerust-analyzer cargo serde_cbor_2 0.13.0 error/ErrorCode#EofWhileParsingValue#, self.offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][`Read<'de>`]offset().())
250 } else {
251 Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::iorust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]io().(e)
252 }
253 })
254 }
255
256 #[inline]
257 fn discardrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][`Read<'de>`]discard().(&mut self) {
258 self.chrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#ch. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
259 }
260
261 fn offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][`Read<'de>`]offset().(&self) -> u64 {
262 self.readerrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#reader..offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/OffsetReader#offset.
263 }
264 }
265
266 #[cfg(feature = "std")]
267 impl<R> Offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/Offset# for IoReadrust-analyzer cargo serde_cbor_2 0.13.0 read/IoRead#<R>
268 where
269 R: 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#,
270 {
271 fn byte_offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][Offset]byte_offset().(&self) -> usize {
272 self.offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`IoRead<R>`][`Read<'de>`]offset().() as usize
273 }
274 }
275
276 #[cfg(feature = "std")]
277 #[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:)]
278 struct OffsetReaderrust-analyzer cargo serde_cbor_2 0.13.0 read/OffsetReader#<R> {
279 readerrust-analyzer cargo serde_cbor_2 0.13.0 read/OffsetReader#reader.: R,
280 offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/OffsetReader#offset.: u64,
281 }
282
283 #[cfg(feature = "std")]
284 impl<R> 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# for OffsetReaderrust-analyzer cargo serde_cbor_2 0.13.0 read/OffsetReader#<R>
285 where
286 R: 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#,
287 {
288 #[inline]
289 fn readrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`OffsetReader<R>`][Read]read().(&mut self, buf: &mut [u8]) -> 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> {
290 let r = self.readerrust-analyzer cargo serde_cbor_2 0.13.0 read/OffsetReader#reader..readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(buf);
291 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(count) = r {
292 self.offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/OffsetReader#offset. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`AddAssign<Self>`]add_assign().count as u64;
293 }
294 r
295 }
296 }
297
298 /// A CBOR input source that reads from a slice of bytes.
299 #[cfg(any(feature = "std", feature = "alloc"))]
300 #[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:)]
301 pub struct SliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#<'a> {
302 slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#slice.: &'a [u8],
303 scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#scratch.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>,
304 indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index.: usize,
305 }
306
307 #[cfg(any(feature = "std", feature = "alloc"))]
308 impl<'a> SliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#<'a> {
309 /// Creates a CBOR input source to read from a slice of bytes.
310 pub fn newrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`]new().(slice: &'a [u8]) -> SliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#<'a> {
311 SliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead# {
312 slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#slice.,
313 scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#scratch.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![],
314 indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index.: 0,
315 }
316 }
317
318 fn endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`]end().(&self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<usize> {
319 match self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index..checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]checked_add().(n) {
320 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end) if end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(end),
321 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]syntax().(
322 ErrorCoderust-analyzer cargo serde_cbor_2 0.13.0 error/ErrorCode#::EofWhileParsingValuerust-analyzer cargo serde_cbor_2 0.13.0 error/ErrorCode#EofWhileParsingValue#,
323 self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u64,
324 )),
325 }
326 }
327 }
328
329 #[cfg(any(feature = "std", feature = "alloc"))]
330 impl Offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/Offset# for SliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#<'_> {
331 #[inline]
332 fn byte_offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'_>`][Offset]byte_offset().(&self) -> usize {
333 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index.
334 }
335 }
336
337 #[cfg(all(
338 any(feature = "std", feature = "alloc"),
339 not(feature = "unsealed_read_write")
340 ))]
341 impl private::Sealed for SliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#<'_> {}
342
343 #[cfg(any(feature = "std", feature = "alloc"))]
344 impl<'a> Readrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#<'a> for SliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#<'a> {
345 #[inline]
346 fn nextrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`][`Read<'a>`]next().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>> {
347 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(if self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index. 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.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
348 let ch = self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
349 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index. 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().1;
350 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ch)
351 } else {
352 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
353 })
354 }
355
356 #[inline]
357 fn peekrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`][`Read<'a>`]peek().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>> {
358 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(if self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index. 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.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
359 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
360 } else {
361 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
362 })
363 }
364
365 fn clear_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`][`Read<'a>`]clear_buffer().(&mut self) {
366 self.scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#scratch..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]clear().();
367 }
368
369 fn read_to_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`][`Read<'a>`]read_to_buffer().(&mut self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> {
370 let end = self.endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`]end().(n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
371 let slice = &self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
372 self.scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#scratch..extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(slice);
373 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index. = end;
374
375 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
376 }
377
378 #[inline]
379 fn readrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`][`Read<'a>`]read().<'b>(&'b mut self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#<'b, 'a>> {
380 let end = self.endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`]end().(n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
381 let slice = &self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
382 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index. = end;
383 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#::Longrust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#Long#(slice))
384 }
385
386 fn take_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`][`Read<'a>`]take_buffer().<'b>(&'b mut self) -> EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#<'b, 'a> {
387 EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#::Shortrust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#Short#(&self.scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#scratch.)
388 }
389
390 #[inline]
391 fn read_intorust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`][`Read<'a>`]read_into().(&mut self, buf: &mut [u8]) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> {
392 let end = self.endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`]end().(buf.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().;
393 buf.copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
394 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index. = end;
395 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
396 }
397
398 #[inline]
399 fn discardrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`][`Read<'a>`]discard().(&mut self) {
400 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index. 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().1;
401 }
402
403 fn offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceRead<'a>`][`Read<'a>`]offset().(&self) -> u64 {
404 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceRead#index. as u64
405 }
406 }
407
408 /// A CBOR input source that reads from a slice of bytes using a fixed size scratch buffer.
409 ///
410 /// [`SliceRead`](struct.SliceRead.html) and [`MutSliceRead`](struct.MutSliceRead.html) are usually
411 /// preferred over this, as they can handle indefinite length items.
412 #[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:)]
413 pub struct SliceReadFixedrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#<'a, 'b> {
414 slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#slice.: &'a [u8],
415 scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch.: &'b mut [u8],
416 indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index.: usize,
417 scratch_indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch_index.: usize,
418 }
419
420 impl<'a, 'b> SliceReadFixedrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#<'a, 'b> {
421 /// Creates a CBOR input source to read from a slice of bytes, backed by a scratch buffer.
422 pub fn newrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, 'b>`]new().(slice: &'a [u8], scratch: &'b mut [u8]) -> SliceReadFixedrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#<'a, 'b> {
423 SliceReadFixedrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed# {
424 slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#slice.,
425 scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch.,
426 indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index.: 0,
427 scratch_indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch_index.: 0,
428 }
429 }
430
431 fn endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, 'b>`]end().(&self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<usize> {
432 match self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index..checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]checked_add().(n) {
433 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end) if end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(end),
434 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]syntax().(
435 ErrorCoderust-analyzer cargo serde_cbor_2 0.13.0 error/ErrorCode#::EofWhileParsingValuerust-analyzer cargo serde_cbor_2 0.13.0 error/ErrorCode#EofWhileParsingValue#,
436 self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u64,
437 )),
438 }
439 }
440
441 fn scratch_endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, 'b>`]scratch_end().(&self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<usize> {
442 match self.scratch_indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch_index..checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]checked_add().(n) {
443 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end) if end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().self.scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(end),
444 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::scratch_too_smallrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]scratch_too_small().(self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index. as u64)),
445 }
446 }
447 }
448
449 #[cfg(not(feature = "unsealed_read_write"))]
450 impl private::Sealed for SliceReadFixedrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#<'_, '_> {}
451
452 impl<'a> Readrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#<'a> for SliceReadFixedrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#<'a, '_> {
453 #[inline]
454 fn nextrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, '_>`][`Read<'a>`]next().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>> {
455 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(if self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index. 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.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
456 let ch = self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
457 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index. 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().1;
458 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ch)
459 } else {
460 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
461 })
462 }
463
464 #[inline]
465 fn peekrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, '_>`][`Read<'a>`]peek().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>> {
466 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(if self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index. 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.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
467 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
468 } else {
469 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
470 })
471 }
472
473 fn clear_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, '_>`][`Read<'a>`]clear_buffer().(&mut self) {
474 self.scratch_indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch_index. = 0;
475 }
476
477 fn read_to_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, '_>`][`Read<'a>`]read_to_buffer().(&mut self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> {
478 let end = self.endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, 'b>`]end().(n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
479 let scratch_end = self.scratch_endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, 'b>`]scratch_end().(n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
480 let slice = &self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
481 self.scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().self.scratch_indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch_index...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#scratch_end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(slice);
482 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index. = end;
483 self.scratch_indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch_index. = scratch_end;
484
485 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
486 }
487
488 fn readrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, '_>`][`Read<'a>`]read().<'c>(&'c mut self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#<'c, 'a>> {
489 let end = self.endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, 'b>`]end().(n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
490 let slice = &self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
491 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index. = end;
492 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#::Longrust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#Long#(slice))
493 }
494
495 fn take_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, '_>`][`Read<'a>`]take_buffer().<'c>(&'c mut self) -> EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#<'c, 'a> {
496 EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#::Shortrust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#Short#(&self.scratchrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.scratch_indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#scratch_index.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
497 }
498
499 #[inline]
500 fn read_intorust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, '_>`][`Read<'a>`]read_into().(&mut self, buf: &mut [u8]) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> {
501 let end = self.endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, 'b>`]end().(buf.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().;
502 buf.copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
503 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index. = end;
504 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
505 }
506
507 #[inline]
508 fn discardrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, '_>`][`Read<'a>`]discard().(&mut self) {
509 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index. 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().1;
510 }
511
512 fn offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'a, '_>`][`Read<'a>`]offset().(&self) -> u64 {
513 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index. as u64
514 }
515 }
516
517 #[cfg(any(feature = "std", feature = "alloc"))]
518 impl Offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/Offset# for SliceReadFixedrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#<'_, '_> {
519 #[inline]
520 fn byte_offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`SliceReadFixed<'_, '_>`][Offset]byte_offset().(&self) -> usize {
521 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/SliceReadFixed#index.
522 }
523 }
524
525 /// A CBOR input source that reads from a slice of bytes, and can move data around internally to
526 /// reassemble indefinite strings without the need of an allocated scratch buffer.
527 #[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:)]
528 pub struct MutSliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#<'a> {
529 /// A complete view of the reader's data. It is promised that bytes before buffer_end are not
530 /// mutated any more.
531 slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice.: &'a mut [u8],
532 /// Read cursor position in slice
533 indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index.: usize,
534 /// Number of bytes already discarded from the slice
535 beforerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#before.: usize,
536 /// End of the buffer area that contains all bytes read_into_buffer. This is always <= index.
537 buffer_endrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#buffer_end.: usize,
538 }
539
540 impl<'a> MutSliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#<'a> {
541 /// Creates a CBOR input source to read from a slice of bytes.
542 pub fn newrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`]new().(slice: &'a mut [u8]) -> MutSliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#<'a> {
543 MutSliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead# {
544 slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice.,
545 indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index.: 0,
546 beforerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#before.: 0,
547 buffer_endrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#buffer_end.: 0,
548 }
549 }
550
551 fn endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`]end().(&self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<usize> {
552 match self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index..checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]checked_add().(n) {
553 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end) if end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(end),
554 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo serde_cbor_2 0.13.0 error/Error#::syntaxrust-analyzer cargo serde_cbor_2 0.13.0 error/impl#[Error]syntax().(
555 ErrorCoderust-analyzer cargo serde_cbor_2 0.13.0 error/ErrorCode#::EofWhileParsingValuerust-analyzer cargo serde_cbor_2 0.13.0 error/ErrorCode#EofWhileParsingValue#,
556 self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as u64,
557 )),
558 }
559 }
560 }
561
562 #[cfg(not(feature = "unsealed_read_write"))]
563 impl private::Sealed for MutSliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#<'_> {}
564
565 impl<'a> Readrust-analyzer cargo serde_cbor_2 0.13.0 read/Read#<'a> for MutSliceReadrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#<'a> {
566 #[inline]
567 fn nextrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`][`Read<'a>`]next().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>> {
568 // This is duplicated from SliceRead, can that be eased?
569 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(if self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index. 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.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
570 let ch = self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
571 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index. 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().1;
572 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ch)
573 } else {
574 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
575 })
576 }
577
578 #[inline]
579 fn peekrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`][`Read<'a>`]peek().(&mut self) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>> {
580 // This is duplicated from SliceRead, can that be eased?
581 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(if self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index. 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.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
582 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
583 } else {
584 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
585 })
586 }
587
588 fn clear_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`][`Read<'a>`]clear_buffer().(&mut self) {
589 self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice. = &mut memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/take().(&mut self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice.)[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index...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().;
590 self.beforerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#before. 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().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index.;
591 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index. = 0;
592 self.buffer_endrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#buffer_end. = 0;
593 }
594
595 fn read_to_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`][`Read<'a>`]read_to_buffer().(&mut self, n: usize) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> {
596 let end = self.endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`]end().(n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
597 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(
598 self.buffer_endrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#buffer_end. <= self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index.,
599 "MutSliceRead invariant violated: scratch buffer exceeds index"
600 );
601 self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().self.buffer_endrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#buffer_end...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..rotate_leftrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]rotate_left().(self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index. 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.buffer_endrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#buffer_end.);
602 self.buffer_endrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#buffer_end. 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().n;
603 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index. = end;
604
605 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
606 }
607
608 fn take_bufferrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`][`Read<'a>`]take_buffer().<'b>(&'b mut self) -> EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#<'b, 'a> {
609 let (left, right) = memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/take().(&mut self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice.).split_at_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at_mut().(self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index.);
610 self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice. = right;
611 self.beforerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#before. 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().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index.;
612 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index. = 0;
613
614 let left = &left[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#self.buffer_endrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#buffer_end.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
615 self.buffer_endrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#buffer_end. = 0;
616
617 EitherLifetimerust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#::Longrust-analyzer cargo serde_cbor_2 0.13.0 read/EitherLifetime#Long#(left)
618 }
619
620 #[inline]
621 fn read_intorust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`][`Read<'a>`]read_into().(&mut self, buf: &mut [u8]) -> Resultrust-analyzer cargo serde_cbor_2 0.13.0 error/Result#<()> {
622 // This is duplicated from SliceRead, can that be eased?
623 let end = self.endrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`]end().(buf.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().;
624 buf.copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&self.slicerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
625 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index. = end;
626 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
627 }
628
629 #[inline]
630 fn discardrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`][`Read<'a>`]discard().(&mut self) {
631 self.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index. 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().1;
632 }
633
634 fn offsetrust-analyzer cargo serde_cbor_2 0.13.0 read/impl#[`MutSliceRead<'a>`][`Read<'a>`]offset().(&self) -> u64 {
635 (self.beforerust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#before. 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.indexrust-analyzer cargo serde_cbor_2 0.13.0 read/MutSliceRead#index.) as u64
636 }
637 }