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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//! Types that encapsulate foreign types into embedded-io writers.
//!
//! Exceeding what the [embedded-io-adapters](https://crates.io/crates/embedded-io-adapters) (which
//! gets co-developed with [`embedded-io`]) does,
//!
//! * it goes both ways: It implements [`embedded_io::Write`] for foreign types ([`WritableCrc`]
//! etc.), but also foreign traits for any implementation of [`embedded_io::Write`]
//! ([`ForeignWritable`]).
//! * it is not too picky in what it implements:
//! * it interfaces with crates that are not stable (e.g. [`digest::Digest`])
//! * it interfaces with crates that are more bespoke but which would still not implement
//! `embedded-io` traits (e.g. [`ciborium_io::Write`])
//!
//! This library is not intended to be part of any other crate's public dependencies, and will do
//! breaking releases whenever its own public dependencies change. Users who want to support
//! different versions of other crates may need to resort to using multiple versions of this crate.
use ;
/// Wrapper around any [`embedded_io::Write`] that implements additional Write-ish traits.
///
/// This implements various CBOR encoders' custom write traits (currently only [`ciborium_io::Write`]).
;
/// Wrapper around any [`digest::Digest`] (typically hashes) that implements [`embedded_io::Write`]
/// to send data into a digest.
;
/// Wrapper around any [`crc::Digest`] (typically hashes) that implements [`embedded_io::Write`]
/// to send data into a digest.
;
//
// FIXME: These were convenient constructors on the WindowedInfinity; should we have them as an
// extension trait on every embedded_ioWrite?
//
/*
/// Create a Tee (a T-shaped writer) that writes both to this WindowedInfinity and some
/// [digest::Digest].
///
/// The resulting type implements all the same writers as the WindowedInfinity, and offers an
/// `into_windowed_and_digest(self) -> (WindowedInfinity, Digest)` to get both back after
/// writing as completed.
pub fn tee_digest<D: digest::Digest>(self) -> TeeForDigest<'a, D> {
tee::Tee {
w1: self,
w2: wrappers::WritableDigest(D::new()),
}
}
/// Create a Tee (a T-shaped writer) that writes both to this WindowedInfinity and some
/// [crc::Digest].
///
/// This is limited to u64 CRCs due to <https://github.com/mrhooray/crc-rs/issues/79>, and
/// indirectly the availability of const traits.
pub fn tee_crc64<'c>(self, crc: &'c crc::Crc<u64>) -> TeeForCrc<'a, 'c, u64> {
tee::Tee {
w1: self,
w2: wrappers::WritableCrc(crc.digest()),
}
}
/// Create a Tee (a T-shaped writer) that writes both to this WindowedInfinity and some
/// [crc::Digest].
///
/// This is limited to u32 CRCs due to <https://github.com/mrhooray/crc-rs/issues/79>, and
/// indirectly the availability of const traits.
pub fn tee_crc32<'c>(self, crc: &'c crc::Crc<u32>) -> TeeForCrc<'a, 'c, u32> {
tee::Tee {
w1: self,
w2: wrappers::WritableCrc(crc.digest()),
}
}
impl<'a, 'c> crate::tee::Tee<crate::WindowedInfinity<'a>, WritableCrc<'c, u64>> {
pub fn into_windowed_and_crc(self) -> (crate::WindowedInfinity<'a>, crc::Digest<'c, u64>) {
(self.w1, self.w2.0)
}
}
impl<'a, 'c> crate::tee::Tee<crate::WindowedInfinity<'a>, WritableCrc<'c, u32>> {
pub fn into_windowed_and_crc(self) -> (crate::WindowedInfinity<'a>, crc::Digest<'c, u32>) {
(self.w1, self.w2.0)
}
}
*/