use read_only::{cast, embed};

#[cast]
pub struct Config {
    #[readonly]
    pub id: u64,
    pub mutable_count: i32,
}

#[embed]
pub struct Device {
    #[readonly]
    pub handle: u64,
    pub mutable: i32,
}

impl Device {
    pub fn new(handle: u64, mutable: i32) -> Self {
        Self {
            read_only: ReadOnlyDevice { handle },
            mutable,
        }
    }
}

fn main() {
    let mut config = Config {
        id: 42,
        mutable_count: 0,
    };
    config.mutable_count += 1;
    println!("config id = {}", config.id);

    let mut device = Device::new(7, 1);
    device.mutable += 1;
    println!("device handle = {}", device.handle);
}
