1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use crate::{DecodeError, DecodeErrorHandler, TopDecode, TopDecodeInput};
pub trait TopDecodeMultiInput: Sized {
type ValueInput: TopDecodeInput;
fn has_next(&self) -> bool;
fn next_value_input<H>(&mut self, h: H) -> Result<Self::ValueInput, H::HandledErr>
where
H: DecodeErrorHandler;
fn next_value<T, H>(&mut self, h: H) -> Result<T, H::HandledErr>
where
T: TopDecode,
H: DecodeErrorHandler,
{
T::top_decode_or_handle_err(self.next_value_input(h)?, h)
}
fn assert_no_more_args<H>(&self, h: H) -> Result<(), H::HandledErr>
where
H: DecodeErrorHandler,
{
if self.has_next() {
Err(h.handle_error(DecodeError::MULTI_TOO_MANY_ARGS))
} else {
Ok(())
}
}
fn flush_ignore<H>(&mut self, h: H) -> Result<(), H::HandledErr>
where
H: DecodeErrorHandler,
{
while self.has_next() {
let _ = self.next_value_input(h)?;
}
Ok(())
}
}