A fairly common I2C operation is checking if an address is present/responding by just writing the address and checking for the device ACK. Note that this is a 0 length read/write and therefore the asserts linked above prevent this.
I see the motivation for preventing 0-sized reads/writes, but there isn't a solid alternative right now. There is some conversation in the embedded-hal crate about adding an explicit method for this but no real consensus or movement.
current master branch asserts that the buffer length for I2C::read and I2C::write is at least 1 and less than 256 (1..=255)
write: https://github.com/stm32-rs/stm32l4xx-hal/blob/master/src/i2c.rs#L254 read: https://github.com/stm32-rs/stm32l4xx-hal/blob/master/src/i2c.rs#L308
A fairly common I2C operation is checking if an address is present/responding by just writing the address and checking for the device ACK. Note that this is a 0 length read/write and therefore the asserts linked above prevent this.
I see the motivation for preventing 0-sized reads/writes, but there isn't a solid alternative right now. There is some conversation in the embedded-hal crate about adding an explicit method for this but no real consensus or movement.