3
3
use core:: { future:: Future , mem:: MaybeUninit } ;
4
4
5
5
/// Async read + write
6
- pub trait ReadWrite < Word > {
6
+ pub trait ReadWrite < Word : ' static > {
7
7
/// Error type
8
8
type Error ;
9
9
10
10
/// Associated future for the `transfer` method.
11
- type ReadWriteFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
11
+ type ReadWriteFuture < ' a > : Future < Output = Result < & ' a [ Word ] , Self :: Error > > + ' a
12
12
where
13
13
Self : ' a ;
14
14
@@ -18,17 +18,19 @@ pub trait ReadWrite<Word> {
18
18
}
19
19
20
20
/// Async read + write in place.
21
- pub trait ReadWriteInPlace < Word > {
21
+ pub trait ReadWriteInPlace < Word : ' static > {
22
22
/// Error type
23
23
type Error ;
24
24
25
25
/// Associated future for the `transfer` method.
26
- type ReadWriteInPlaceFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
26
+ type ReadWriteInPlaceFuture < ' a > : Future < Output = Result < & ' a [ Word ] , Self :: Error > > + ' a
27
27
where
28
28
Self : ' a ;
29
29
30
30
/// Writes `words` to the slave from the `readwrite` buffer and reads words into the same buffer.
31
31
/// This method uses a single `readwrite` buffer.
32
+ ///
33
+ /// The returned buffer is the initialized `readwrite` buffer.
32
34
fn readwrite_inplace < ' a > ( & ' a mut self , readwrite : & ' a mut [ Word ] ) -> Self :: ReadWriteInPlaceFuture < ' a > ;
33
35
}
34
36
@@ -47,17 +49,19 @@ pub trait Write<Word> {
47
49
}
48
50
49
51
/// Async read
50
- pub trait Read < Word > {
52
+ pub trait Read < Word : ' static > {
51
53
/// Error type
52
54
type Error ;
53
55
54
56
/// Associated future for the `read` method.
55
- type ReadFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
57
+ type ReadFuture < ' a > : Future < Output = Result < & ' a [ Word ] , Self :: Error > > + ' a
56
58
where
57
59
Self : ' a ;
58
60
59
61
/// Reads words from the slave without specifying any data to write.
60
62
/// The SPI hardware will send data, though what data it sends is not defined
61
- /// by this trait. Some hardware can configure what values (e.g. all zeroes, all ones), some cannot.
63
+ /// by this trait. Some hardware can configure what values (e.g. 0x00, 0xFF), some cannot.
64
+ ///
65
+ /// The returned buffer is the initialized `words` buffer.
62
66
fn read < ' a > ( & ' a mut self , words : & ' a mut [ MaybeUninit < Word > ] ) -> Self :: ReadFuture < ' a > ;
63
67
}
0 commit comments