@@ -147,6 +147,14 @@ pub mod blocking {
147147 fn read ( & mut self , address : A , buffer : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > ;
148148 }
149149
150+ impl < A : AddressMode , T : Read < A > > Read < A > for & mut T {
151+ type Error = T :: Error ;
152+
153+ fn read ( & mut self , address : A , buffer : & mut [ u8 ] ) -> Result < ( ) , Self :: Error > {
154+ ( * self ) . read ( address, buffer)
155+ }
156+ }
157+
150158 /// Blocking write
151159 pub trait Write < A : AddressMode = SevenBitAddress > {
152160 /// Error type
@@ -171,6 +179,14 @@ pub mod blocking {
171179 fn write ( & mut self , address : A , bytes : & [ u8 ] ) -> Result < ( ) , Self :: Error > ;
172180 }
173181
182+ impl < A : AddressMode , T : Write < A > > Write < A > for & mut T {
183+ type Error = T :: Error ;
184+
185+ fn write ( & mut self , address : A , bytes : & [ u8 ] ) -> Result < ( ) , Self :: Error > {
186+ ( * self ) . write ( address, bytes)
187+ }
188+ }
189+
174190 /// Blocking write (iterator version)
175191 pub trait WriteIter < A : AddressMode = SevenBitAddress > {
176192 /// Error type
@@ -186,6 +202,17 @@ pub mod blocking {
186202 B : IntoIterator < Item = u8 > ;
187203 }
188204
205+ impl < A : AddressMode , T : WriteIter < A > > WriteIter < A > for & mut T {
206+ type Error = T :: Error ;
207+
208+ fn write_iter < B > ( & mut self , address : A , bytes : B ) -> Result < ( ) , Self :: Error >
209+ where
210+ B : IntoIterator < Item = u8 > ,
211+ {
212+ ( * self ) . write_iter ( address, bytes)
213+ }
214+ }
215+
189216 /// Blocking write + read
190217 pub trait WriteRead < A : AddressMode = SevenBitAddress > {
191218 /// Error type
@@ -221,6 +248,19 @@ pub mod blocking {
221248 ) -> Result < ( ) , Self :: Error > ;
222249 }
223250
251+ impl < A : AddressMode , T : WriteRead < A > > WriteRead < A > for & mut T {
252+ type Error = T :: Error ;
253+
254+ fn write_read (
255+ & mut self ,
256+ address : A ,
257+ bytes : & [ u8 ] ,
258+ buffer : & mut [ u8 ] ,
259+ ) -> Result < ( ) , Self :: Error > {
260+ ( * self ) . write_read ( address, bytes, buffer)
261+ }
262+ }
263+
224264 /// Blocking write (iterator version) + read
225265 pub trait WriteIterRead < A : AddressMode = SevenBitAddress > {
226266 /// Error type
@@ -242,6 +282,22 @@ pub mod blocking {
242282 B : IntoIterator < Item = u8 > ;
243283 }
244284
285+ impl < A : AddressMode , T : WriteIterRead < A > > WriteIterRead < A > for & mut T {
286+ type Error = T :: Error ;
287+
288+ fn write_iter_read < B > (
289+ & mut self ,
290+ address : A ,
291+ bytes : B ,
292+ buffer : & mut [ u8 ] ,
293+ ) -> Result < ( ) , Self :: Error >
294+ where
295+ B : IntoIterator < Item = u8 > ,
296+ {
297+ ( * self ) . write_iter_read ( address, bytes, buffer)
298+ }
299+ }
300+
245301 /// Transactional I2C operation.
246302 ///
247303 /// Several operations can be combined as part of a transaction.
@@ -280,6 +336,18 @@ pub mod blocking {
280336 ) -> Result < ( ) , Self :: Error > ;
281337 }
282338
339+ impl < A : AddressMode , T : Transactional < A > > Transactional < A > for & mut T {
340+ type Error = T :: Error ;
341+
342+ fn exec < ' a > (
343+ & mut self ,
344+ address : A ,
345+ operations : & mut [ Operation < ' a > ] ,
346+ ) -> Result < ( ) , Self :: Error > {
347+ ( * self ) . exec ( address, operations)
348+ }
349+ }
350+
283351 /// Transactional I2C interface (iterator version).
284352 ///
285353 /// This allows combining operation within an I2C transaction.
@@ -304,4 +372,15 @@ pub mod blocking {
304372 where
305373 O : IntoIterator < Item = Operation < ' a > > ;
306374 }
375+
376+ impl < A : AddressMode , T : TransactionalIter < A > > TransactionalIter < A > for & mut T {
377+ type Error = T :: Error ;
378+
379+ fn exec_iter < ' a , O > ( & mut self , address : A , operations : O ) -> Result < ( ) , Self :: Error >
380+ where
381+ O : IntoIterator < Item = Operation < ' a > > ,
382+ {
383+ ( * self ) . exec_iter ( address, operations)
384+ }
385+ }
307386}
0 commit comments