Skip to content

Commit c7e35cd

Browse files
authored
Make fields in UnknownCmsg public (#2520)
* fix: make fields in UnknownCmsg public * chore: changelog * fix: mess caused by format on save * fix: mess caused by format on save * feat: make the type visible in the doc * chore: update changelog
1 parent 4cba73b commit c7e35cd

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

changelog/2520.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Made `nix::sys::socket::UnknownCmsg` public and more readable

src/sys/socket/mod.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,6 @@ pub enum ControlMessageOwned {
846846
TlsGetRecordType(TlsGetRecordType),
847847

848848
/// Catch-all variant for unimplemented cmsg types.
849-
#[doc(hidden)]
850849
Unknown(UnknownCmsg),
851850
}
852851

@@ -1062,7 +1061,10 @@ impl ControlMessageOwned {
10621061
},
10631062
(_, _) => {
10641063
let sl = unsafe { std::slice::from_raw_parts(p, len) };
1065-
let ucmsg = UnknownCmsg(*header, Vec::<u8>::from(sl));
1064+
let ucmsg = UnknownCmsg {
1065+
cmsg_header: *header,
1066+
data_bytes: Vec::<u8>::from(sl),
1067+
};
10661068
ControlMessageOwned::Unknown(ucmsg)
10671069
}
10681070
}
@@ -1255,10 +1257,14 @@ pub enum ControlMessage<'a> {
12551257
Ipv6TClass(&'a i32),
12561258
}
12571259

1258-
// An opaque structure used to prevent cmsghdr from being a public type
1259-
#[doc(hidden)]
1260+
/// Control messages that are currently not supported by Nix.
12601261
#[derive(Clone, Debug, Eq, PartialEq)]
1261-
pub struct UnknownCmsg(cmsghdr, Vec<u8>);
1262+
pub struct UnknownCmsg {
1263+
/// Control message header.
1264+
pub cmsg_header: cmsghdr,
1265+
/// Bytes of the control message data.
1266+
pub data_bytes: Vec<u8>
1267+
}
12621268

12631269
impl ControlMessage<'_> {
12641270
/// The value of CMSG_SPACE on this message.

0 commit comments

Comments
 (0)