Skip to content

Consider making ControlMessageOwned::decode_from public #2613

Open
@redbaron

Description

@redbaron

My IO layer is built around io_uring, where multishot results gives access to control messages buffer as raw bytes and it is up to the app to parse it.

I could get by with libc to iterate over headers:

        let hdr: RecvMsgOut = io_uring::types::RecvMsgOut::parse(buf)?;

        // Fake msghdr to iterate over control messages
        let mut mhdr = new_msghdr();
        mhdr.msg_controllen = hdr.control_data().len() as _;
        mhdr.msg_control = hdr.control_data().as_ptr() as _;

        // SAFETY: msghdr.msg_controllen and msghdr.msg_control are valid
        unsafe {
            let mut cmsghdr = libc::CMSG_FIRSTHDR(std::ptr::addr_of!(mhdr));
            while !cmsghdr.is_null() {
                let cmsg = &*cmsghdr;
                // ControlMessageOwned::decode_from();
                cmsghdr = libc::CMSG_NXTHDR(&mhdr as *const _, cmsghdr);
            }
        }

but interpreting each header remains fairly low level. This crate contains most complete ergonomic handler for each individual control message type I could find, but it doesn't expose it publically. Maybe you could change ControlMessageOwned::decode_from to pub?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions