use std::fmt;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum LinkError {
NoProc,
NoCaller,
}
impl fmt::Display for LinkError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NoProc => f.write_str("target process does not exist"),
Self::NoCaller => f.write_str("caller process identity unknown"),
}
}
}
impl std::error::Error for LinkError {}
pub trait LinkFacility: Send + Sync {
fn link(&self, caller_pid: u64, target_pid: u64) -> Result<(), LinkError>;
fn unlink(&self, caller_pid: u64, target_pid: u64) -> Result<(), LinkError>;
fn set_trap_exit(&self, caller_pid: u64, value: bool) -> Result<bool, LinkError>;
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum LinkRecord {
Link {
caller_pid: u64,
target_pid: u64,
},
Unlink {
caller_pid: u64,
target_pid: u64,
},
}