1use std::io;
2
3use crate::backend::Backend;
4use crate::backend::ops::ext::ExtBackend;
5
6use super::{Config, Driver};
7
8pub trait DriverExt: Sized {
9 fn new(cfg: Config) -> io::Result<Self>;
10 fn init_thread(cpu_id: u16) -> io::Result<()>;
11 fn allowed_cpus() -> io::Result<Vec<u16>>;
12}
13
14impl DriverExt for Driver {
15 fn new(cfg: Config) -> io::Result<Self> {
16 cfg.validate()?;
17 let (state, slots) = <Backend as ExtBackend>::create(&cfg)?;
18 Driver::from_state(state, slots, cfg.ready_slots, cfg.provided.entries as usize)
19 }
20
21 fn init_thread(cpu_id: u16) -> io::Result<()> {
22 <Backend as ExtBackend>::init_thread(cpu_id)
23 }
24
25 fn allowed_cpus() -> io::Result<Vec<u16>> {
26 <Backend as ExtBackend>::allowed_cpus()
27 }
28}