use crate::connection::NetFn; #[derive(Clone, Debug, PartialEq)] pub enum IpmiError { NetFnIsResponse(NetFn), UnexpectedResponse { netfn_sent: NetFn, netfn_recvd: NetFn, cmd_sent: u8, cmd_recvd: u8, }, ParsingFailed { error: P, netfn: NetFn, cmd: u8, completion_code: u8, data: Vec, }, Connection(CON), } impl From for IpmiError { fn from(value: CON) -> Self { Self::Connection(value) } } impl IpmiError { pub fn map(self, f: F) -> IpmiError where F: FnOnce(CON) -> CON2, { match self { IpmiError::NetFnIsResponse(v) => IpmiError::NetFnIsResponse(v), IpmiError::UnexpectedResponse { netfn_sent, netfn_recvd, cmd_sent, cmd_recvd, } => IpmiError::UnexpectedResponse { netfn_sent, netfn_recvd, cmd_sent, cmd_recvd, }, IpmiError::ParsingFailed { error, netfn, cmd, completion_code, data, } => IpmiError::ParsingFailed { error, netfn, cmd, completion_code, data, }, IpmiError::Connection(e) => IpmiError::Connection(f(e)), } } }