"basically, using it to "bundle..." <- > <@jamesmunns:beeper.com> basically, using it to "bundle" a bunch of metadata into a single entity. For I2C registers, you might have something like: > > ``` > pub trait WriteReg { > type AddrTy; > type Val > type Endianness: EndianTy; > const RegAddr: Self::AddrTy; > } > > impl WriteReg for SampleRate { > type AddrTy = u8; // 8-bit register addr > type Val = u16; // 16-bit register value > type Endianness = BigEndian; // data in reg is big endian > const RegAddr: Self::AddrTy = 0x45; // register address > } > ``` > > Then do: > > ```rust > // set sample rate to 4khz > i2c.write_reg::(DEV_I2C_ADDR, 4000u16).await?; > ``` Yes, I like this pattern too. I've been exploring it in `colstodian`, in particular the `ColorEncoding` type https://fu5ha.github.io/colstodian/colstodian/trait.ColorEncoding.html