use dope_core::driver::RecvMsgOutView;

pub struct RecvMsgOut;

impl RecvMsgOutView for RecvMsgOut {
    fn parse_with<R>(
        raw: &[u8],
        msghdr: &libc::msghdr,
        f: impl FnOnce(&[u8], &[u8]) -> R,
    ) -> Option<R> {
        let parsed = io_uring::types::RecvMsgOut::parse(raw, msghdr).ok()?;
        let name = parsed.name_data();
        let payload = parsed.payload_data();
        Some(f(name, payload))
    }
}
