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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Extension traits for ergonomic operations on encoding and decoding.
//!
//! These traits provide convenience methods (like `read()`, `decode()`, `read_range()`, and
//! `decode_range()`) that simplify common use cases of the core [`Read`] and [`Decode`] traits,
//! particularly when default configurations (`()`) or [`RangeCfg`] are involved.
use crate::;
use Buf;
/// Extension trait providing ergonomic read method for types requiring no configuration
/// (i.e. `Cfg = ()`).
///
/// Import this trait to use the `.read(buf)` method as a shorthand for `.read_cfg(buf, ())`.
// Automatically implement `ReadExt` for types that implement `Read` with no config.
/// Extension trait providing ergonomic decode method for types requiring no specific configuration.
///
/// Import this trait to use the `.decode(buf)` method as a shorthand for `.decode_cfg(buf, ())`.
// Automatically implement `DecodeExt` for types that implement `Decode` with no config.
/// Extension trait for reading types whose config is `(RangeCfg, X)` where `X` is [`Default`].
///
/// Useful for reading collections like [`Vec<T>`] where `T` implements [`Read`] with no specific
/// configuration. Import this trait to use the `.read_range()` method.
// Automatically implement `ReadRangeExt` for types that implement `Read` with config
// `(RangeCfg, X)`, where `X` is `Default`.
/// Extension trait for reading types whose config is `(RangeCfg, X)` where `X` is [`Default`],
/// ensuring the buffer is consumed.
///
/// Useful for decoding collections like [`Vec<T>`] where `T` implements [`Read`] with no specific
/// configuration. Import this trait to use the `.decode_range()` method.
// Automatically implement `DecodeRangeExt` for types that implement `Decode` with config
// `(RangeCfg, X)`, where `X` has a default implementation.