1
1
//! Blocking SPI API
2
2
3
3
/// Blocking transfer with separate buffers
4
- pub trait Transfer < W = u8 > {
4
+ pub trait Transfer < W : Copy = u8 > {
5
5
/// Error type
6
6
type Error : crate :: spi:: Error ;
7
7
@@ -16,7 +16,7 @@ pub trait Transfer<W = u8> {
16
16
fn transfer ( & mut self , read : & mut [ W ] , write : & [ W ] ) -> Result < ( ) , Self :: Error > ;
17
17
}
18
18
19
- impl < T : Transfer < W > , W > Transfer < W > for & mut T {
19
+ impl < T : Transfer < W > , W : Copy > Transfer < W > for & mut T {
20
20
type Error = T :: Error ;
21
21
22
22
fn transfer ( & mut self , read : & mut [ W ] , write : & [ W ] ) -> Result < ( ) , Self :: Error > {
@@ -25,7 +25,7 @@ impl<T: Transfer<W>, W> Transfer<W> for &mut T {
25
25
}
26
26
27
27
/// Blocking transfer with single buffer (in-place)
28
- pub trait TransferInplace < W = u8 > {
28
+ pub trait TransferInplace < W : Copy = u8 > {
29
29
/// Error type
30
30
type Error : crate :: spi:: Error ;
31
31
@@ -35,7 +35,7 @@ pub trait TransferInplace<W = u8> {
35
35
fn transfer_inplace ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > ;
36
36
}
37
37
38
- impl < T : TransferInplace < W > , W > TransferInplace < W > for & mut T {
38
+ impl < T : TransferInplace < W > , W : Copy > TransferInplace < W > for & mut T {
39
39
type Error = T :: Error ;
40
40
41
41
fn transfer_inplace ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > {
@@ -44,7 +44,7 @@ impl<T: TransferInplace<W>, W> TransferInplace<W> for &mut T {
44
44
}
45
45
46
46
/// Blocking read
47
- pub trait Read < W = u8 > {
47
+ pub trait Read < W : Copy = u8 > {
48
48
/// Error type
49
49
type Error : crate :: spi:: Error ;
50
50
@@ -55,7 +55,7 @@ pub trait Read<W = u8> {
55
55
fn read ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > ;
56
56
}
57
57
58
- impl < T : Read < W > , W > Read < W > for & mut T {
58
+ impl < T : Read < W > , W : Copy > Read < W > for & mut T {
59
59
type Error = T :: Error ;
60
60
61
61
fn read ( & mut self , words : & mut [ W ] ) -> Result < ( ) , Self :: Error > {
@@ -64,15 +64,15 @@ impl<T: Read<W>, W> Read<W> for &mut T {
64
64
}
65
65
66
66
/// Blocking write
67
- pub trait Write < W = u8 > {
67
+ pub trait Write < W : Copy = u8 > {
68
68
/// Error type
69
69
type Error : crate :: spi:: Error ;
70
70
71
71
/// Writes `words` to the slave, ignoring all the incoming words
72
72
fn write ( & mut self , words : & [ W ] ) -> Result < ( ) , Self :: Error > ;
73
73
}
74
74
75
- impl < T : Write < W > , W > Write < W > for & mut T {
75
+ impl < T : Write < W > , W : Copy > Write < W > for & mut T {
76
76
type Error = T :: Error ;
77
77
78
78
fn write ( & mut self , words : & [ W ] ) -> Result < ( ) , Self :: Error > {
@@ -81,7 +81,7 @@ impl<T: Write<W>, W> Write<W> for &mut T {
81
81
}
82
82
83
83
/// Blocking write (iterator version)
84
- pub trait WriteIter < W = u8 > {
84
+ pub trait WriteIter < W : Copy = u8 > {
85
85
/// Error type
86
86
type Error : crate :: spi:: Error ;
87
87
@@ -91,7 +91,7 @@ pub trait WriteIter<W = u8> {
91
91
WI : IntoIterator < Item = W > ;
92
92
}
93
93
94
- impl < T : WriteIter < W > , W > WriteIter < W > for & mut T {
94
+ impl < T : WriteIter < W > , W : Copy > WriteIter < W > for & mut T {
95
95
type Error = T :: Error ;
96
96
97
97
fn write_iter < WI > ( & mut self , words : WI ) -> Result < ( ) , Self :: Error >
@@ -106,7 +106,7 @@ impl<T: WriteIter<W>, W> WriteIter<W> for &mut T {
106
106
///
107
107
/// This allows composition of SPI operations into a single bus transaction
108
108
#[ derive( Debug , PartialEq ) ]
109
- pub enum Operation < ' a , W : ' static = u8 > {
109
+ pub enum Operation < ' a , W : ' static + Copy = u8 > {
110
110
/// Read data into the provided buffer.
111
111
Read ( & ' a mut [ W ] ) ,
112
112
/// Write data from the provided buffer, discarding read data
@@ -119,15 +119,15 @@ pub enum Operation<'a, W: 'static = u8> {
119
119
120
120
/// Transactional trait allows multiple actions to be executed
121
121
/// as part of a single SPI transaction
122
- pub trait Transactional < W : ' static = u8 > {
122
+ pub trait Transactional < W : ' static + Copy = u8 > {
123
123
/// Associated error type
124
124
type Error : crate :: spi:: Error ;
125
125
126
126
/// Execute the provided transactions
127
127
fn exec < ' a > ( & mut self , operations : & mut [ Operation < ' a , W > ] ) -> Result < ( ) , Self :: Error > ;
128
128
}
129
129
130
- impl < T : Transactional < W > , W : ' static > Transactional < W > for & mut T {
130
+ impl < T : Transactional < W > , W : ' static + Copy > Transactional < W > for & mut T {
131
131
type Error = T :: Error ;
132
132
133
133
fn exec < ' a > ( & mut self , operations : & mut [ Operation < ' a , W > ] ) -> Result < ( ) , Self :: Error > {
0 commit comments