<re_irc>
<richarddodd> almindor: All Rust ownership is 'virtual' in the end - none of it is present in the final binary (unless you count runtime techniques like reference counting).
<re_irc>
<richarddodd> So I don't think what the HAL is doing is different in spirit to any other rust ownership code. I regularly introduce 'virtual' lifetimes and ownership when wrapping C APIs to embed the documented lifetime invariants in the types themselves
dc740 has quit [Remote host closed the connection]
dc740 has quit [Remote host closed the connection]
<re_irc>
<omar_u8> AM trying to create a function that looks like this "fn send_array<const P: char, const N: u8, SPI, PINS>( arr: &[u8], per: &Spi<SPI, PINS, TransferModeNormal>, cs: &Pin<P, N, Output>, ) -> Result<(), stm32f4xx_hal::spi::Error> { cs.set_low(); per.write(&arr); cs.set_high(); }" though I'm getting an error on the write method
<re_irc>
<omar_u8> AM trying to create a function that looks like this "fn send_array<const P: char, const N: u8, SPI, PINS>( arr: &[u8], per: &Spi<SPI, PINS, TransferModeNormal>, cs: &Pin<P, N, Output>, ) -> Result<(), stm32f4xx_hal::spi::Error> { cs.set_low(); per.write(&arr); cs.set_high(); }" though I'm getting an error on the write method
<re_irc>
<omar_u8> I'm trying to create a function that looks like this
<re_irc>
"fn send_array<const P: char, const N: u8, SPI, PINS>( arr: &[u8], per: &Spi<SPI, PINS, TransferModeNormal>, cs: &Pin<P, N, Output>, ) -> Result<(), stm32f4xx_hal::spi::Error> { cs.set_low(); per.write(&arr); cs.set_high(); }" though I'm getting an error on the write method
<re_irc>
<omar_u8> I'm trying to create a function that looks like this
<re_irc>
which is required by `&Spi<SPI, PINS>: stm32f4xx_hal::prelude::_embedded_hal_blocking_spi_Write<_>````
<re_irc>
<omar_u8> "the method `write` exists for reference `&Spi<SPI, PINS>`, but its trait bounds were not satisfied the following trait bounds were not satisfied: `&Spi<SPI, PINS>: stm32f4xx_hal::embedded_hal::blocking::spi::write::Default<_>` which is required by \`&Spi\<SPI, PINS>: stm32f4xx\_hal::prelude::_embedded\_hal\_blocking\_spi\_Write\<_\>"
<re_irc>
<dirbaio> change "&Spi, &Pin" to "&mut Spi, &mut Pin"
<re_irc>
<omar_u8> That didnt do it 😟
<re_irc>
<omar_u8> The error message just added the word "mutable" to it :D
<re_irc>
<omar_u8> * 😀
<re_irc>
<dirbaio> ahh, you need to restrict the generics with "where" clauses so that Spi<..> and Pin<..> are valid
<re_irc>
<dirbaio> usually copying the "where" clauses on these struct
<re_irc>
<dirbaio> * structs
<re_irc>
<dirbaio> but it's easier to use embedded-hal