Skip to content

Commit

Permalink
Add ControlMessage::copy_to_slice; used with stack allocation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillikin committed Oct 27, 2023
1 parent d57ff25 commit c2bb793
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions text/3430-unix-socket-ancillary-data-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,26 @@ impl ControlMessage<'a> {
cmsg_type: c_int,
data: &'a [u8],
) -> ControlMessage<'a>;
}

impl ControlMessage<'_> {
// Opaque platform-specific integers; same as `struct cmsghdr` fields.
fn cmsg_level(&self) -> c_int;
fn cmsg_type(&self) -> c_int;

// The type-specific data of this control message.
fn data(&self) -> &[u8];

// How big the encoded cmsg is; same as `CMSG_SPACE()`.
fn cmsg_space(&self) -> usize;

// Whether this control message is truncated, such as by being received
// into a too-short buffer.
fn truncated(&self) -> bool;

// Encodes the cmsg according to local OS conventions. `dst` must be
// `cmsg_space()` bytes long.
fn copy_to_slice<'a>(&self, dst: &'a mut [MaybeUninit<u8>]) -> &'a [u8];
}
```

Expand Down

0 comments on commit c2bb793

Please sign in to comment.