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
71
72
73
74
75
76
77
78
79
80
81
/*
* SPDX-FileCopyrightText: 2023 Inria
* SPDX-FileCopyrightText: 2023 Sebastiano Vigna
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*/
//! No-std support for reading while keeping track of the current position.
use crate*;
/// [`std::io::Read`]-like trait for deserialization that does not depend on
/// [`std`].
///
/// In an [`std`] context, the user does not need to use directly this trait as
/// we provide a blanket implementation that implements [`ReadNoStd`] for all
/// types that implement [`std::io::Read`]. In particular, in such a context you
/// can use [`AlignedCursor`] for ε-copy deserialization.
///
/// [`std::io::Read`]: https://doc.rust-lang.org/std/io/trait.Read.html
/// [`std`]: https://doc.rust-lang.org/std/
use Read;
/// Byte slices are readers consuming themselves from the front, mirroring the
/// [`std::io::Read`] implementation for `&[u8]`. This impl is gated like the
/// [`ReadNoStd`] impl for [`AlignedCursor`]: when `std` is available, byte
/// slices are covered by the blanket implementation, and a second
/// implementation would conflict with it.
///
/// [`std::io::Read`]: https://doc.rust-lang.org/std/io/trait.Read.html
/// A trait for [`ReadNoStd`] that also keeps track of the current position.
///
/// This is needed because the [`Read`] trait doesn't have a `seek` method and
/// [`std::io::Seek`] would be a requirement much stronger than needed.
///
/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html
/// [`std::io::Seek`]: https://doc.rust-lang.org/std/io/trait.Seek.html