diff --git a/embedded-hal-async/src/i2c.rs b/embedded-hal-async/src/i2c.rs index 404d37ba7..e74282630 100644 --- a/embedded-hal-async/src/i2c.rs +++ b/embedded-hal-async/src/i2c.rs @@ -107,9 +107,10 @@ pub trait I2c: ErrorType { ) -> Self::WriteReadFuture<'a>; /// Future returned by the `transaction` method. - type TransactionFuture<'a>: Future> + 'a + type TransactionFuture<'a, 'b>: Future> + 'a where - Self: 'a; + Self: 'a, + 'b: 'a; /// Execute the provided operations on the I2C bus as a single transaction. /// @@ -124,11 +125,11 @@ pub trait I2c: ErrorType { /// - `SAD+R/W` = slave address followed by bit 1 to indicate reading or 0 to indicate writing /// - `SR` = repeated start condition /// - `SP` = stop condition - fn transaction<'a>( + fn transaction<'a, 'b>( &'a mut self, address: A, - operations: &mut [Operation<'a>], - ) -> Self::TransactionFuture<'a>; + operations: &'a mut [Operation<'b>], + ) -> Self::TransactionFuture<'a, 'b>; } impl> I2c for &mut T { @@ -164,16 +165,17 @@ impl> I2c for &mut T { T::write_read(self, address, bytes, buffer) } - type TransactionFuture<'a> + type TransactionFuture<'a, 'b> where Self: 'a, - = T::TransactionFuture<'a>; + 'b: 'a, + = T::TransactionFuture<'a, 'b>; - fn transaction<'a>( + fn transaction<'a, 'b>( &'a mut self, address: A, - operations: &mut [Operation<'a>], - ) -> Self::TransactionFuture<'a> { + operations: &'a mut [Operation<'b>], + ) -> Self::TransactionFuture<'a, 'b> { T::transaction(self, address, operations) } } diff --git a/src/i2c.rs b/src/i2c.rs index 9707a4632..9b6298da4 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -244,7 +244,7 @@ impl ErrorType for &mut T { /// Address mode (7-bit / 10-bit) /// /// Note: This trait is sealed and should not be implemented outside of this crate. -pub trait AddressMode: private::Sealed {} +pub trait AddressMode: private::Sealed + 'static {} /// 7-bit address mode type pub type SevenBitAddress = u8;