Split up the SPI trait into several with shared Error associated type.
This commit is contained in:
parent
372884422a
commit
22901938ce
@ -18,25 +18,39 @@ use core::future::Future;
|
||||
///
|
||||
/// - Some SPIs can work with 8-bit *and* 16-bit words. You can overload this trait with different
|
||||
/// `Word` types to allow operation in both modes.
|
||||
pub trait FullDuplex<Word> {
|
||||
|
||||
pub trait Spi<Word> {
|
||||
/// An enumeration of SPI errors
|
||||
type Error;
|
||||
}
|
||||
|
||||
pub trait FullDuplex<Word> : Spi<Word> + Write<Word> + Read<Word> {
|
||||
|
||||
type WriteFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
|
||||
where
|
||||
Self: 'a;
|
||||
type ReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
|
||||
where
|
||||
Self: 'a;
|
||||
type WriteReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'a>;
|
||||
fn write<'a>(&'a mut self, data: &'a [Word]) -> Self::WriteFuture<'a>;
|
||||
fn read_write<'a>(
|
||||
&'a mut self,
|
||||
read: &'a mut [Word],
|
||||
write: &'a [Word],
|
||||
) -> Self::WriteReadFuture<'a>;
|
||||
}
|
||||
|
||||
pub trait Write<Word> : Spi<Word>{
|
||||
|
||||
type WriteFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
fn write<'a>(&'a mut self, data: &'a [Word]) -> Self::WriteFuture<'a>;
|
||||
}
|
||||
|
||||
pub trait Read<Word> : Spi<Word>{
|
||||
|
||||
type ReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'a>;
|
||||
}
|
Loading…
Reference in New Issue
Block a user