feat(schemev2): detach

This commit adds:
* `CqeOpcode::RespondAndNotifyOnDetach`
* `Opcode::Detach`

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh
2026-02-20 19:57:28 +11:00
parent 374b33f2e4
commit 0a7bf437bd
+13
View File
@@ -91,21 +91,31 @@ pub enum CqeOpcode {
SendFevent, // no tag
ObtainFd,
RespondWithMultipleFds,
/// [`SchemeAsync::on_close`] and [`SchemeSync::on_close`] are only called when the last file
/// descriptor referring to the file description is closed. To implement traditional POSIX
/// advisory file locking, [`CqeOpcode::RespondAndNotifyOnDetach`] is used to notify the scheme
/// by sending a [`RequestKind::OnDetach`] request the next time the file description is
/// "detached" from a file descriptor. Not done by default to avoid unnecessary IPC.
RespondAndNotifyOnDetach,
// TODO: ProvideMmap
}
impl CqeOpcode {
pub fn try_from_raw(raw: u8) -> Option<Self> {
// TODO: Use a library where this match can be automated.
Some(match raw {
0 => Self::RespondRegular,
1 => Self::RespondWithFd,
2 => Self::SendFevent,
3 => Self::ObtainFd,
4 => Self::RespondWithMultipleFds,
5 => Self::RespondAndNotifyOnDetach,
_ => return None,
})
}
}
/// SqeOpcode
#[repr(u8)]
#[non_exhaustive]
#[derive(Clone, Copy, Debug)]
@@ -146,6 +156,8 @@ pub enum Opcode {
UnlinkAt = 32, // fd, path_ptr, path_len (utf8), flags
StdFsCall = 33,
Detach = 34,
}
impl Opcode {
@@ -189,6 +201,7 @@ impl Opcode {
32 => UnlinkAt,
33 => StdFsCall,
34 => Detach,
_ => return None,
})