INNER CODE UNIT · Rust
read_coils
slowtec/tokio-modbus · src/client/mod.rs:150
async fn read_coils<'a>(&'a mut self, addr: Address, cnt: Quantity) -> Result<Vec<Coil>> {
self.client
.call(Request::ReadCoils(addr, cnt))
.await
.map(|result| {
result.map(|response| match response {
Response::ReadCoils(mut coils) => {
debug_assert!(coils.len() >= cnt.into());
coils.truncate(cnt.into());
coils
}
_ => unreachable!("call() should reject mismatching responses"),
})
})
}
async fn read_discrete_inputs<'a>(
&'a mut self,