embedded_platform/i2c/
begin_write.rs1use core::future;
3use core::pin;
4use core::task;
5
6#[derive(Debug)]
8#[must_use = "futures do nothing unless you `.await` or poll them"]
9pub struct BeginWrite<'a, A>
10where
11 A: super::I2cWrite + Unpin + ?Sized,
12{
13 writer: &'a mut A,
14 address: u8,
15}
16
17pub fn begin_write<A>(writer: &mut A, address: u8) -> BeginWrite<A>
21where
22 A: super::I2cWrite + Unpin + ?Sized,
23{
24 BeginWrite { writer, address }
25}
26
27impl<A> future::Future for BeginWrite<'_, A>
28where
29 A: super::I2cWrite + Unpin + ?Sized,
30{
31 type Output = Result<A::Write, A::Error>;
32
33 fn poll(mut self: pin::Pin<&mut Self>, cx: &mut task::Context<'_>) -> task::Poll<Self::Output> {
34 let this = &mut *self;
35 pin::Pin::new(&mut *this.writer).poll_begin_write(cx, this.address)
36 }
37}