File tree 2 files changed +50
-0
lines changed
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,22 @@ pub trait Write {
50
50
fn write ( & mut self , addr : u8 , bytes : & [ u8 ] ) -> Result < ( ) , Self :: Error > ;
51
51
}
52
52
53
+ /// Blocking write (iterator version)
54
+ #[ cfg( feature = "unproven" ) ]
55
+ pub trait WriteIter {
56
+ /// Error type
57
+ type Error ;
58
+
59
+ /// Sends bytes to slave with address `addr`
60
+ ///
61
+ /// # I2C Events (contract)
62
+ ///
63
+ /// Same as `Write`
64
+ fn write < B > ( & mut self , addr : u8 , bytes : B ) -> Result < ( ) , Self :: Error >
65
+ where
66
+ B : IntoIterator < Item = u8 > ;
67
+ }
68
+
53
69
/// Blocking write + read
54
70
pub trait WriteRead {
55
71
/// Error type
@@ -84,3 +100,25 @@ pub trait WriteRead {
84
100
buffer : & mut [ u8 ] ,
85
101
) -> Result < ( ) , Self :: Error > ;
86
102
}
103
+
104
+ /// Blocking write (iterator version) + read
105
+ #[ cfg( feature = "unproven" ) ]
106
+ pub trait WriteIterRead {
107
+ /// Error type
108
+ type Error ;
109
+
110
+ /// Sends bytes to slave with address `addr` and then reads enough bytes to fill `buffer` *in a
111
+ /// single transaction*
112
+ ///
113
+ /// # I2C Events (contract)
114
+ ///
115
+ /// Same as the `WriteRead` trait
116
+ fn write_iter_read < B > (
117
+ & mut self ,
118
+ address : u8 ,
119
+ bytes : B ,
120
+ buffer : & mut [ u8 ] ,
121
+ ) -> Result < ( ) , Self :: Error >
122
+ where
123
+ B : IntoIterator < Item = u8 > ;
124
+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,18 @@ pub trait Write<W> {
18
18
fn write ( & mut self , words : & [ W ] ) -> Result < ( ) , Self :: Error > ;
19
19
}
20
20
21
+ /// Blocking write (iterator version)
22
+ #[ cfg( feature = "unproven" ) ]
23
+ pub trait WriteIter < W > {
24
+ /// Error type
25
+ type Error ;
26
+
27
+ /// Sends `words` to the slave, ignoring all the incoming words
28
+ fn write_iter < WI > ( & mut self , words : WI ) -> Result < ( ) , Self :: Error >
29
+ where
30
+ WI : IntoIterator < Item = W > ;
31
+ }
32
+
21
33
/// Blocking transfer
22
34
pub mod transfer {
23
35
/// Default implementation of `blocking::spi::Transfer<W>` for implementers of
You can’t perform that action at this time.
0 commit comments