Debian Codegraph @

src/decoding/decoder.rs

raw symbols SCIP
1 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!;
2 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/;
3
4 use craterust-analyzer cargo bendy 0.6.1 crate/::{
5 decodingrust-analyzer cargo bendy 0.6.1 decoding/::{Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#, Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#},
6 state_trackerrust-analyzer cargo bendy 0.6.1 state_tracker/::{StateTrackerrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#, StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#, Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#},
7 };
8
9 /// A bencode decoder
10 ///
11 /// This can be used to either get a stream of tokens (using the [`Decoder::tokens()`] method) or to
12 /// read a complete object at a time (using the [`Decoder::next_object()`]) method.
13 #[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:)]
14 pub struct Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#<'a> {
15 sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source.: &'a [u8],
16 offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset.: usize,
17 staterust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#state.: StateTrackerrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#<&'a [u8], Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#>,
18 }
19
20 impl<'ser> Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#<'ser> {
21 /// Create a new decoder from the given byte array
22 pub fn newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(buffer: &'ser [u8]) -> Selfrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`] {
23 Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder# {
24 sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source.: buffer,
25 offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset.: 0,
26 staterust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#state.: StateTrackerrust-analyzer cargo bendy 0.6.1 state_tracker/state/StateTracker#::newrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]new().(),
27 }
28 }
29
30 /// Set the maximum nesting depth of the decoder. An unlimited-depth decoder may be
31 /// created using `with_max_depth(<usize>::max_value())`, but be warned that this will likely
32 /// exhaust memory if the nesting depth is too deep (even when reading raw tokens)
33 pub fn with_max_depthrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]with_max_depth().(mut self, new_max_depth: usize) -> Selfrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`] {
34 self.staterust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#state..set_max_depthrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]set_max_depth().(new_max_depth);
35 self
36 }
37
38 fn take_byterust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]take_byte().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8> {
39 if self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset. 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.sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
40 let ret = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
41 self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset. 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;
42 ret
43 } else {
44 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
45 }
46 }
47
48 fn take_chunkrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]take_chunk().(&mut self, count: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'ser [u8]> {
49 match self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset..checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]checked_add().(count) {
50 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(end_pos) if end_pos 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.sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() => {
51 let ret = &self.sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end_pos]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
52 self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset. = end_pos;
53 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ret)
54 },
55 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
56 }
57 }
58
59 fn take_intrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]take_int().(&mut self, expected_terminator: char) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&'ser str, StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#> {
60 enum Staterust-analyzer cargo bendy 0.6.1 decoding/decoder/State# {
61 Startrust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Start#,
62 Signrust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Sign#,
63 Zerorust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Zero#,
64 Digitsrust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Digits#,
65 }
66
67 let mut curpos = self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset.;
68 let mut state = Staterust-analyzer cargo bendy 0.6.1 decoding/decoder/State#::Startrust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Start#;
69 let mut success = false;
70 while curpos 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.sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
71 let c = self.sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().curpos]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). as char;
72 state = match state {
73 Staterust-analyzer cargo bendy 0.6.1 decoding/decoder/State#::Startrust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Start# => match c {
74 '-' => Staterust-analyzer cargo bendy 0.6.1 decoding/decoder/State#::Signrust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Sign#,
75 '0' => Staterust-analyzer cargo bendy 0.6.1 decoding/decoder/State#::Zerorust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Zero#,
76 '0'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'9' => Staterust-analyzer cargo bendy 0.6.1 decoding/decoder/State#::Digitsrust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Digits#,
77 _ => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::unexpectedrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/impl#[StructureError]unexpected().("'-' or '0'..'9'", c, curpos)),
78 },
79 Staterust-analyzer cargo bendy 0.6.1 decoding/decoder/State#::Zerorust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Zero# => {
80 if c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().expected_terminator {
81 success = true;
82 break;
83 } else {
84 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::unexpectedrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/impl#[StructureError]unexpected().(
85 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{expected_terminator:?}"),
86 c,
87 curpos,
88 ));
89 }
90 },
91 Staterust-analyzer cargo bendy 0.6.1 decoding/decoder/State#::Signrust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Sign# => match c {
92 '1'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'9' => Staterust-analyzer cargo bendy 0.6.1 decoding/decoder/State#::Digitsrust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Digits#,
93 _ => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::unexpectedrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/impl#[StructureError]unexpected().("'1'..'9'", c, curpos)),
94 },
95 Staterust-analyzer cargo bendy 0.6.1 decoding/decoder/State#::Digitsrust-analyzer cargo bendy 0.6.1 decoding/decoder/State#Digits# => match c {
96 '0'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'9' => state,
97 x if x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().expected_terminator => {
98 success = true;
99 break;
100 },
101 _ => {
102 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::unexpectedrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/impl#[StructureError]unexpected().(
103 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{expected_terminator:?} or '0'..'9'"),
104 c,
105 curpos,
106 ));
107 },
108 },
109 };
110 curpos 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;
111 }
112
113 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().success {
114 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::UnexpectedEofrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#UnexpectedEof#);
115 }
116
117 #[cfg(feature = "debug")]
118 let ival = strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(&self.sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#curpos]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
119 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("We've already examined every byte in the string");
120
121 #[cfg(not(feature="debug"))]
122 let ival = // Avoid a second UTF-8 check here
123 unsafe { strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::from_utf8_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8_unchecked().(&self.source[self.offset..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#curpos]) };
124
125 self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset. = curpos 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().1;
126
127 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ival)
128 }
129
130 fn raw_next_tokenrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]raw_next_token().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#<'ser>, Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#> {
131 let token = match self.take_byterust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]take_byte().().ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::UnexpectedEofrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#UnexpectedEof#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). as char {
132 'e' => Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::Endrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#End#,
133 'l' => Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::Listrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#List#,
134 'd' => Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::Dictrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Dict#,
135 'i' => Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::Numrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Num#(self.take_intrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]take_int().('e')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
136 '0'..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#'9' => {
137 self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset. 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;
138 let curpos = self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset.;
139 let ival = self.take_intrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]take_int().(':')?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
140 let len: usize = str::parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().(ival).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::SyntaxErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#SyntaxError# {
141 unexpectedrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#SyntaxError#unexpected.: formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Invalid integer at offset {curpos}"),
142 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
143 Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::Stringrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#String#(self.take_chunkrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]take_chunk().(len).ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::UnexpectedEofrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#UnexpectedEof#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
144 },
145 tok => {
146 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#::fromrust-analyzer cargo bendy 0.6.1 decoding/error/impl#[Error][`From<state_tracker::StructureError>`]from().(StructureErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#::SyntaxErrorrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#SyntaxError# {
147 unexpectedrust-analyzer cargo bendy 0.6.1 state_tracker/structure_error/StructureError#SyntaxError#unexpected.: formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
148 "Invalid token starting with {:?} at offset {}",
149 tok,
150 self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset. -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). 1
151 ),
152 }));
153 },
154 };
155
156 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(token)
157 }
158
159 /// Read the next token. Returns Ok(Some(token)) if a token was successfully read,
160 fn next_tokenrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_token().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#<'ser>>, Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#> {
161 self.staterust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#state..check_errorrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]check_error().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
162
163 if self.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset. 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().self.sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
164 self.staterust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#state..observe_eofrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]observe_eof().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
165 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#);
166 }
167
168 let tok_result = self.raw_next_tokenrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]raw_next_token().();
169 let tok = self.staterust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#state..latch_errrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]latch_err().(tok_result)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
170 self.staterust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#state..observe_tokenrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]observe_token().(&tok)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
171 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#(tok))
172 }
173
174 /// Iterate over the tokens in the input stream. This guarantees that the resulting stream
175 /// of tokens constitutes a valid bencoded structure.
176 pub fn tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]tokens().(self) -> Tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/Tokens#<'ser> {
177 Tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/Tokens#(self)
178 }
179 }
180
181 /// Iterator over the tokens in the input stream. This guarantees that the resulting stream
182 /// of tokens constitutes a valid bencoded structure.
183 pub struct Tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/Tokens#<'a>(Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#<'a>);
184
185 impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/Tokens#<'a> {
186 type Itemrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Tokens<'a>`][Iterator]Item# = Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#<'a>, Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#>;
187
188 fn nextrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Tokens<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Tokens<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
189 // Only report an error once
190 if self.0rust-analyzer cargo bendy 0.6.1 decoding/decoder/Tokens#0..staterust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#state..check_errorrust-analyzer cargo bendy 0.6.1 state_tracker/state/impl#[`StateTracker<S, E>`]check_error().().is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().() {
191 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
192 }
193 match self.0rust-analyzer cargo bendy 0.6.1 decoding/decoder/Tokens#0..next_tokenrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_token().() {
194 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#(token)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(token)),
195 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#) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
196 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err)),
197 }
198 }
199 }
200
201 // High level interface
202
203 impl<'ser> Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#<'ser> {
204 /// Read the next object from the encoded stream
205 ///
206 /// If the beginning of an object was successfully read, returns `Ok(Some(object))`.
207 /// At the end of the input stream, this will return `Ok(None)`; otherwise, returns
208 /// `Err(some_error)`.
209 ///
210 /// Note that complex objects (lists and dicts) are not fully validated before being
211 /// returned from this method, so you may still get an error while decoding the contents
212 /// of the object
213 pub fn next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().<'obj>(&'obj mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#<'obj, 'ser>>, Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#> {
214 use selfrust-analyzer cargo bendy 0.6.1 decoding/decoder/::Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::*;
215 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match self.next_tokenrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_token().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). {
216 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Endrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#End#) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
217 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Listrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#List#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Listrust-analyzer cargo bendy 0.6.1 decoding/object/Object#List#(ListDecoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`ListDecoder<'obj, 'ser>`]new().(self))),
218 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Dictrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Dict#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Dictrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Dict#(DictDecoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`DictDecoder<'obj, 'ser>`]new().(self))),
219 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Stringrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#String#(s)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Bytesrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Bytes#(s)),
220 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Numrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Num#(s)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Integerrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Integer#(s)),
221 })
222 }
223 }
224
225 /// A dictionary read from the input stream
226 #[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:)]
227 pub struct DictDecoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#<'obj, 'ser: 'obj> {
228 decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#decoder.: &'obj mut Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#<'ser>,
229 finishedrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#finished.: bool,
230 start_pointrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#start_point.: usize,
231 }
232
233 /// A list read from the input stream
234 #[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:)]
235 pub struct ListDecoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#<'obj, 'ser: 'obj> {
236 decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#decoder.: &'obj mut Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#<'ser>,
237 finishedrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#finished.: bool,
238 start_pointrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#start_point.: usize,
239 }
240
241 impl<'obj, 'ser: 'obj> DictDecoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#<'obj, 'ser> {
242 fn newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`DictDecoder<'obj, 'ser>`]new().(decoder: &'obj mut Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#<'ser>) -> Selfrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`DictDecoder<'obj, 'ser>`] {
243 let offset = decoder.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset. 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().1;
244 DictDecoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder# {
245 decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#decoder.,
246 finishedrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#finished.: false,
247 start_pointrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#start_point.: offset,
248 }
249 }
250
251 /// Parse the next key/value pair from the dictionary. Returns `Ok(None)`
252 /// at the end of the dictionary
253 pub fn next_pairrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`DictDecoder<'obj, 'ser>`]next_pair().<'item>(
254 &'item mut self,
255 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&'ser [u8], Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#<'item, 'ser>)>, Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#> {
256 if self.finishedrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#finished. {
257 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#);
258 }
259
260 // We convert to a token to release the mut ref to decoder
261 let key = self.decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#decoder..next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::into_tokenrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]into_token().);
262
263 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::Stringrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#String#(k)) = key {
264 // This unwrap should be safe because None would produce an error here
265 let v = self.decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#decoder..next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
266 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#((k, v)))
267 } else {
268 // We can't have gotten anything but a string, as anything else would be
269 // a state error
270 self.finishedrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#finished. = true;
271 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#)
272 }
273 }
274
275 /// Consume (and validate the structure of) the rest of the items from the
276 /// dictionary. This method should be used to check for encoding errors if
277 /// [`DictDecoder::next_pair`] is not called until it returns `Ok(None)`.
278 pub fn consume_allrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`DictDecoder<'obj, 'ser>`]consume_all().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#> {
279 while self.next_pairrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`DictDecoder<'obj, 'ser>`]next_pair().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
280 // just drop the items
281 }
282 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
283 }
284
285 /// Get the raw bytes that made up this dictionary
286 pub fn into_rawrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`DictDecoder<'obj, 'ser>`]into_raw().(mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&'ser [u8], Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#> {
287 self.consume_allrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`DictDecoder<'obj, 'ser>`]consume_all().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
288 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&self.decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#decoder..sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.start_pointrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#start_point...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#decoder..offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
289 }
290 }
291
292 impl<'obj, 'ser: 'obj> Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for DictDecoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/DictDecoder#<'obj, 'ser> {
293 fn droprust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`DictDecoder<'obj, 'ser>`][Drop]drop().(&mut self) {
294 // we don't care about errors in drop; they'll be reported again in the parent
295 self.consume_allrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`DictDecoder<'obj, 'ser>`]consume_all().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().();
296 }
297 }
298
299 impl<'obj, 'ser: 'obj> ListDecoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#<'obj, 'ser> {
300 fn newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`ListDecoder<'obj, 'ser>`]new().(decoder: &'obj mut Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#<'ser>) -> Selfrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`ListDecoder<'obj, 'ser>`] {
301 let offset = decoder.offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset. 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().1;
302 ListDecoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder# {
303 decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#decoder.,
304 finishedrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#finished.: false,
305 start_pointrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#start_point.: offset,
306 }
307 }
308
309 /// Get the next item from the list. Returns `Ok(None)` at the end of the list
310 pub fn next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`ListDecoder<'obj, 'ser>`]next_object().<'item>(&'item mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#<'item, 'ser>>, Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#> {
311 if self.finishedrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#finished. {
312 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#);
313 }
314
315 let item = self.decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#decoder..next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
316 if item.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() {
317 self.finishedrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#finished. = true;
318 }
319
320 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(item)
321 }
322
323 /// Consume (and validate the structure of) the rest of the items from the
324 /// list. This method should be used to check for encoding errors if
325 /// [`ListDecoder::next_object`] is not called until it returns [`Ok(())`].
326 ///
327 /// [`Ok(())`]: https://doc.rust-lang.org/std/result/enum.Result.html#variant.Ok
328 pub fn consume_allrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`ListDecoder<'obj, 'ser>`]consume_all().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#> {
329 while self.next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`ListDecoder<'obj, 'ser>`]next_object().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
330 // just drop the items
331 }
332 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
333 }
334
335 /// Get the raw bytes that made up this list
336 pub fn into_rawrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`ListDecoder<'obj, 'ser>`]into_raw().(mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&'ser [u8], Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#> {
337 self.consume_allrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`ListDecoder<'obj, 'ser>`]consume_all().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
338 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&self.decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#decoder..sourcerust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#source.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.start_pointrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#start_point...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#decoder..offsetrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#offset.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
339 }
340 }
341
342 impl<'obj, 'ser: 'obj> Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for ListDecoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/ListDecoder#<'obj, 'ser> {
343 fn droprust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`ListDecoder<'obj, 'ser>`][Drop]drop().(&mut self) {
344 // we don't care about errors in drop; they'll be reported again in the parent
345 self.consume_allrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`ListDecoder<'obj, 'ser>`]consume_all().().okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().();
346 }
347 }
348
349 #[cfg(test)]
350 mod testrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/ {
351
352 #[cfg(not(feature = "std"))]
353 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#};
354 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/;
355
356 use regexrust-analyzer cargo regex 1.6.0 crate/;
357
358 use superrust-analyzer cargo bendy 0.6.1 decoding/decoder/::*;
359
360 static SIMPLE_MSGrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/SIMPLE_MSG.: &'static [u8] = b"d3:bari1e3:fooli2ei3eee";
361
362 fn decode_tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_tokens().(msg: &[u8]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#<'_>> {
363 let tokens: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#, Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#>> = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(msg).tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]tokens().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
364 if tokens.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#::is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().) {
365 tokens.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#::unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
366 } else {
367 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!(
368 "Unexpected tokenization error. Received tokens: {:?}",
369 tokens
370 );
371 }
372 }
373
374 fn decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(msg: &[u8], err_regex: &str) {
375 let mut tokens: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#, Errorrust-analyzer cargo bendy 0.6.1 decoding/error/Error#>> = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(msg).tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]tokens().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
376 if tokens.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#::is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().) {
377 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Unexpected parse success: {:?}", tokens);
378 } else {
379 let err = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", tokens.poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().().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().());
380 let err_regex = regexrust-analyzer cargo regex 1.6.0 crate/::Regexrust-analyzer cargo regex 1.6.0 re_unicode/Regex#::newrust-analyzer cargo regex 1.6.0 re_unicode/impl#[Regex]new().(err_regex).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Test regexes should be valid");
381 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().err_regex.is_matchrust-analyzer cargo regex 1.6.0 re_unicode/impl#[Regex]is_match().(&err) {
382 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Unexpected error: {}", err);
383 }
384 }
385 }
386
387 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
388 fn simple_bdecode_tokenizationrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/simple_bdecode_tokenization().() {
389 use selfrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/::Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::*;
390 let tokens: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = decode_tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_tokens().(SIMPLE_MSGrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/SIMPLE_MSG.);
391 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
392 tokens,
393 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
394 Dictrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Dict#,
395 Stringrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#String#(&b"bar"[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/index/Index#index().),
396 Numrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Num#(&"1"[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/index/Index#index().),
397 Stringrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#String#(&b"foo"[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/index/Index#index().),
398 Listrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#List#,
399 Numrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Num#(&"2"[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/index/Index#index().),
400 Numrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Num#(&"3"[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/index/Index#index().),
401 Endrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#End#,
402 Endrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#End#,
403 ]
404 );
405 }
406
407 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
408 fn short_dict_should_failrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/short_dict_should_fail().() {
409 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"d", r"EOF");
410 }
411
412 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
413 fn short_list_should_failrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/short_list_should_fail().() {
414 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"l", r"EOF");
415 }
416
417 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
418 fn short_int_should_failrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/short_int_should_fail().() {
419 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"i12", r"EOF");
420 }
421
422 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
423 fn negative_numbers_and_zero_should_parserust-analyzer cargo bendy 0.6.1 decoding/decoder/test/negative_numbers_and_zero_should_parse().() {
424 use selfrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/::Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::*;
425 let tokens: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = decode_tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_tokens().(b"i0ei-1e");
426 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tokens, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Numrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Num#(&"0"), Numrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Num#(&"-1")],);
427 }
428
429 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
430 fn negative_zero_is_illegalrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/negative_zero_is_illegal().() {
431 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"i-0e", "got '0'");
432 }
433
434 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
435 fn leading_zeros_are_illegalrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/leading_zeros_are_illegal().() {
436 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"i00e", "got '0'");
437 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"i-00e", "got '0'");
438
439 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"i01e", "got '1'");
440 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"i-01e", "got '0'");
441
442 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"i001e", "got '0'");
443 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"i-001e", "got '0'");
444 }
445
446 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
447 fn map_keys_must_be_stringsrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/map_keys_must_be_strings().() {
448 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"d3:fooi1ei2ei3ee", r"Map keys must be strings");
449 }
450
451 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
452 fn map_keys_must_ascendrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/map_keys_must_ascend().() {
453 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"d3:fooi1e3:bari1ee", r"Keys were not sorted");
454 }
455
456 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
457 fn map_keys_must_be_uniquerust-analyzer cargo bendy 0.6.1 decoding/decoder/test/map_keys_must_be_unique().() {
458 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"d3:fooi1e3:fooi1ee", r"Keys were not sorted");
459 }
460
461 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
462 fn map_keys_must_have_valuesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/map_keys_must_have_values().() {
463 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"d3:fooe", r"Missing map value");
464 }
465
466 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
467 fn strings_must_have_bodiesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/strings_must_have_bodies().() {
468 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"3:", r"EOF");
469 }
470
471 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
472 fn ints_must_have_bodiesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/ints_must_have_bodies().() {
473 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(b"ie", r"Expected.*got 'e'");
474 }
475
476 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
477 fn recursion_should_be_limitedrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/recursion_should_be_limited().() {
478 let mut msg = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
479 msg.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat/repeat().(b'l').takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(4096));
480 msg.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::repeatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/repeat/repeat().(b'e').takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(4096));
481 decode_errrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/decode_err().(&msg, r"nesting depth");
482 }
483
484 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
485 fn recursion_bounds_should_be_tightrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/recursion_bounds_should_be_tight().() {
486 let test_msg = b"lllleeee";
487 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
488 Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(test_msg)
489 .with_max_depthrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]with_max_depth().(4)
490 .tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]tokens().()
491 .lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#last().()
492 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
493 .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()
494 );
495 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
496 Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(test_msg)
497 .with_max_depthrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]with_max_depth().(3)
498 .tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]tokens().()
499 .lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#last().()
500 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
501 .is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()
502 );
503 }
504
505 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
506 fn dict_drop_should_consume_structrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/dict_drop_should_consume_struct().() {
507 let mut decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"d3:fooi1e3:quxi2eei1000e");
508 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(decoder.next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().());
509
510 let token = decoder.tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]tokens().().nextrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Tokens<'a>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
511 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token, Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::Numrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Num#("1000"));
512 }
513
514 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
515 fn list_drop_should_consume_structrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/list_drop_should_consume_struct().() {
516 let mut decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"li1ei2ei3eei1000e");
517 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(decoder.next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().());
518
519 let token = decoder.tokensrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]tokens().().nextrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Tokens<'a>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
520 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(token, Tokenrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#::Numrust-analyzer cargo bendy 0.6.1 state_tracker/token/Token#Num#("1000"));
521 }
522
523 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
524 fn bytes_or_should_work_on_bytesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/bytes_or_should_work_on_bytes().() {
525 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
526 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&b"foo"[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/index/Index#index().),
527 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Bytesrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Bytes#(b"foo").bytes_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]bytes_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
528 );
529 }
530
531 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
532 fn bytes_or_should_not_work_on_other_typesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/bytes_or_should_not_work_on_other_types().() {
533 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
534 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
535 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Integerrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Integer#("123").bytes_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]bytes_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
536 );
537
538 let mut list_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"le");
539 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
540 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
541 list_decoder
542 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
543 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
544 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
545 .bytes_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]bytes_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
546 );
547 let mut dict_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"de");
548 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
549 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
550 dict_decoder
551 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
552 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
553 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
554 .bytes_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]bytes_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
555 );
556 }
557
558 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
559 fn bytes_or_else_should_work_on_bytesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/bytes_or_else_should_work_on_bytes().() {
560 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
561 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&b"foo"[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/index/Index#index().),
562 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Bytesrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Bytes#(b"foo").bytes_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]bytes_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
563 );
564 }
565
566 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
567 fn bytes_or_else_should_not_work_on_other_typesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/bytes_or_else_should_not_work_on_other_types().() {
568 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
569 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
570 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Integerrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Integer#("123").bytes_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]bytes_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
571 );
572 let mut list_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"le");
573 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
574 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
575 list_decoder
576 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
577 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
578 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
579 .bytes_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]bytes_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
580 );
581 let mut dict_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"de");
582 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
583 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
584 dict_decoder
585 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
586 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
587 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
588 .bytes_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]bytes_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
589 );
590 }
591
592 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
593 fn integer_str_or_should_work_on_intrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/integer_str_or_should_work_on_int().() {
594 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
595 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&"123"[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/index/Index#index().),
596 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Integerrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Integer#("123").integer_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]integer_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
597 );
598 }
599
600 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
601 fn integer_str_or_should_not_work_on_other_typesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/integer_str_or_should_not_work_on_other_types().() {
602 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
603 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
604 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Bytesrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Bytes#(b"foo").integer_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]integer_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
605 );
606 let mut list_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"le");
607 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
608 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
609 list_decoder
610 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
611 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
612 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
613 .integer_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]integer_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
614 );
615 let mut dict_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"de");
616 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
617 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
618 dict_decoder
619 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
620 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
621 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
622 .integer_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]integer_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
623 );
624 }
625
626 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
627 fn integer_str_or_else_should_work_on_intrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/integer_str_or_else_should_work_on_int().() {
628 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
629 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&"123"[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/index/Index#index().),
630 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Integerrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Integer#("123").integer_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]integer_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
631 );
632 }
633
634 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
635 fn integer_str_or_else_should_not_work_on_other_typesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/integer_str_or_else_should_not_work_on_other_types().() {
636 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
637 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
638 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Bytesrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Bytes#(b"foo").integer_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]integer_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
639 );
640 let mut list_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"le");
641 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
642 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
643 list_decoder
644 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
645 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
646 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
647 .integer_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]integer_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
648 );
649 let mut dict_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"de");
650 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
651 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"),
652 dict_decoder
653 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
654 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
655 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
656 .integer_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]integer_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
657 );
658 }
659
660 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
661 fn list_or_should_work_on_listrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/list_or_should_work_on_list().() {
662 let mut list_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"le");
663 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
664 list_decoder
665 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
666 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
667 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
668 .list_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]list_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
669 .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()
670 );
671 }
672 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
673 fn list_or_should_not_work_on_other_typesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/list_or_should_not_work_on_other_types().() {
674 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
675 "failure",
676 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Bytesrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Bytes#(b"foo").list_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]list_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure")).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
677 );
678 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
679 "failure",
680 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Integerrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Integer#("foo").list_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]list_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure")).unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
681 );
682
683 let mut dict_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"de");
684 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
685 "failure",
686 dict_decoder
687 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
688 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
689 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
690 .list_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]list_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
691 .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
692 );
693 }
694
695 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
696 fn list_or_else_should_work_on_listrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/list_or_else_should_work_on_list().() {
697 let mut list_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"le");
698 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
699 list_decoder
700 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
701 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
702 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
703 .list_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]list_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
704 .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()
705 );
706 }
707 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
708 fn list_or_else_should_not_work_on_other_typesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/list_or_else_should_not_work_on_other_types().() {
709 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
710 "failure",
711 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Bytesrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Bytes#(b"foo")
712 .list_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]list_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
713 .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
714 );
715 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
716 "failure",
717 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Integerrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Integer#("foo")
718 .list_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]list_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
719 .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
720 );
721
722 let mut dict_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"de");
723 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
724 "failure",
725 dict_decoder
726 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
727 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
728 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
729 .list_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]list_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
730 .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
731 );
732 }
733
734 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
735 fn dictionary_or_should_work_on_dictrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/dictionary_or_should_work_on_dict().() {
736 let mut dict_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"de");
737 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
738 dict_decoder
739 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
740 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
741 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
742 .dictionary_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]dictionary_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
743 .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()
744 );
745 }
746
747 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
748 fn dictionary_or_should_not_work_on_other_typesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/dictionary_or_should_not_work_on_other_types().() {
749 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
750 "failure",
751 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Bytesrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Bytes#(b"foo")
752 .dictionary_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]dictionary_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
753 .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
754 );
755 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
756 "failure",
757 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Integerrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Integer#("foo")
758 .dictionary_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]dictionary_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
759 .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
760 );
761
762 let mut list_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"le");
763 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
764 "failure",
765 list_decoder
766 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
767 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
768 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
769 .dictionary_orrust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]dictionary_or().(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
770 .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
771 );
772 }
773
774 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
775 fn dictionary_or_else_should_work_on_dictrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/dictionary_or_else_should_work_on_dict().() {
776 let mut dict_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"de");
777 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
778 dict_decoder
779 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
780 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
781 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
782 .dictionary_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]dictionary_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
783 .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()
784 );
785 }
786
787 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
788 fn dictionary_or_else_should_not_work_on_other_typesrust-analyzer cargo bendy 0.6.1 decoding/decoder/test/dictionary_or_else_should_not_work_on_other_types().() {
789 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
790 "failure",
791 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Bytesrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Bytes#(b"foo")
792 .dictionary_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]dictionary_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
793 .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
794 );
795 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
796 "failure",
797 Objectrust-analyzer cargo bendy 0.6.1 decoding/object/Object#::Integerrust-analyzer cargo bendy 0.6.1 decoding/object/Object#Integer#("foo")
798 .dictionary_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]dictionary_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
799 .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
800 );
801
802 let mut list_decoder = Decoderrust-analyzer cargo bendy 0.6.1 decoding/decoder/Decoder#::newrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]new().(b"le");
803 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
804 "failure",
805 list_decoder
806 .next_objectrust-analyzer cargo bendy 0.6.1 decoding/decoder/impl#[`Decoder<'ser>`]next_object().()
807 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
808 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
809 .dictionary_or_elserust-analyzer cargo bendy 0.6.1 decoding/object/impl#[`Object<'obj, 'ser>`]dictionary_or_else().(|_| Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("failure"))
810 .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().()
811 );
812 }
813 }