twizzler_driver/device/
children.rs1use twizzler::object::ObjID;
2use twizzler_abi::kso::{KactionCmd, KactionFlags, KactionGenericCmd};
3
4use super::Device;
5
6pub struct DeviceChildrenIterator {
8 pub(crate) id: ObjID,
9 pub(crate) pos: u16,
10}
11
12impl Iterator for DeviceChildrenIterator {
13 type Item = Device;
14 fn next(&mut self) -> Option<Self::Item> {
15 let cmd = KactionCmd::Generic(KactionGenericCmd::GetChild(self.pos));
16 let result =
17 twizzler_abi::syscall::sys_kaction(cmd, Some(self.id), 0, 0, KactionFlags::empty())
18 .ok()?;
19 self.pos += 1;
20 result.objid().map(|id| Device::new(id).ok()).flatten()
21 }
22}
23
24impl Device {
25 pub fn children(&self) -> DeviceChildrenIterator {
27 DeviceChildrenIterator {
28 id: self.obj.id(),
29 pos: 0,
30 }
31 }
32}