RTIC. Is it able to use generic resources?

I use an RTIC for project on the STM32.
I need to store in the "local" struct some generic type. For example embedded_hal::blocking::i2c::Write + embedded_hal::blocking::i2c::WriteRead.
Is it able?

Thanks!

You will need to make your struct generic.

use embedded_hal::blocking::i2c::{Write, WriteRead};

struct MyDriver<I> {
    i2c: I,
}

impl<I> MyDriver<I>
where 
    I: Write + WriteRead
{
    pub fn new(i2c: I) -> Self { MyDriver { i2c } }

    pub fn do_stuff(&mut self) -> Result<(), I::Error> {
        self.i2c.write_read(...)?;
        todo!()
    }
}

In this case i need to store the MyDriver into the "local" as generic too.

    #[local]
    struct Local<I>
    {
        driver: MyDriver<I>
    }