Skip to content

Commit c2bb793

Browse files
committed
Add ControlMessage::copy_to_slice; used with stack allocation.
1 parent d57ff25 commit c2bb793

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

text/3430-unix-socket-ancillary-data-v2.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,26 @@ impl ControlMessage<'a> {
147147
cmsg_type: c_int,
148148
data: &'a [u8],
149149
) -> ControlMessage<'a>;
150+
}
150151

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

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

160+
// How big the encoded cmsg is; same as `CMSG_SPACE()`.
161+
fn cmsg_space(&self) -> usize;
162+
158163
// Whether this control message is truncated, such as by being received
159164
// into a too-short buffer.
160165
fn truncated(&self) -> bool;
166+
167+
// Encodes the cmsg according to local OS conventions. `dst` must be
168+
// `cmsg_space()` bytes long.
169+
fn copy_to_slice<'a>(&self, dst: &'a mut [MaybeUninit<u8>]) -> &'a [u8];
161170
}
162171
```
163172

0 commit comments

Comments
 (0)