Skip to content

Commit a91fd73

Browse files
committed
Add doc comments
1 parent 46764d4 commit a91fd73

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

library/std/src/sys/unix/ext/net/ancillary.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ impl<'a, T> Iterator for AncillaryDataIter<'a, T> {
158158
}
159159
}
160160

161+
/// Unix credential.
161162
#[cfg(any(
162163
doc,
163164
target_os = "android",
@@ -191,42 +192,54 @@ pub struct UCred(libc::ucred);
191192
target_env = "uclibc",
192193
))]
193194
impl UCred {
195+
/// Create a Unix credential struct.
196+
///
197+
/// PID, UID and GID is set to 0.
194198
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
195199
pub fn new() -> UCred {
196200
UCred(libc::ucred { pid: 0, uid: 0, gid: 0 })
197201
}
198202

203+
/// Set the PID.
199204
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
200205
pub fn set_pid(&mut self, pid: i32) {
201206
self.0.pid = pid;
202207
}
203208

209+
/// Get the current PID.
204210
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
205211
pub fn get_pid(&self) -> i32 {
206212
self.0.pid
207213
}
208214

215+
/// Set the UID.
209216
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
210217
pub fn set_uid(&mut self, uid: u32) {
211218
self.0.uid = uid;
212219
}
213220

221+
/// Get the current UID.
214222
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
215223
pub fn get_uid(&self) -> u32 {
216224
self.0.uid
217225
}
218226

227+
/// Set the GID.
219228
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
220229
pub fn set_gid(&mut self, gid: u32) {
221230
self.0.gid = gid;
222231
}
223232

233+
/// Get the current GID.
224234
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
225235
pub fn get_gid(&self) -> u32 {
226236
self.0.gid
227237
}
228238
}
229239

240+
/// This control message contains file descriptors.
241+
///
242+
/// The level is equal to `SOL_SOCKET` and the type is equal to `SCM_RIGHTS`.
230243
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
231244
pub struct ScmRights<'a>(AncillaryDataIter<'a, RawFd>);
232245

@@ -239,6 +252,9 @@ impl<'a> Iterator for ScmRights<'a> {
239252
}
240253
}
241254

255+
/// This control message contains unix credentials.
256+
///
257+
/// The level is equal to `SOL_SOCKET` and the type is equal to `SCM_CREDENTIALS` or `SCM_CREDS`.
242258
#[cfg(any(
243259
doc,
244260
target_os = "android",
@@ -279,13 +295,15 @@ impl<'a> Iterator for ScmCredentials<'a> {
279295
}
280296
}
281297

298+
/// The error type which is returned from parsing the type a control message.
282299
#[non_exhaustive]
283300
#[derive(Debug)]
284301
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
285302
pub enum AncillaryError {
286303
Unknown { cmsg_level: i32, cmsg_type: i32 },
287304
}
288305

306+
/// This enum represent one control message of variable type.
289307
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
290308
pub enum AncillaryData<'a> {
291309
ScmRights(ScmRights<'a>),
@@ -372,6 +390,7 @@ impl<'a> AncillaryData<'a> {
372390
}
373391
}
374392

393+
/// This struct is used to iterate through the control messages.
375394
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
376395
pub struct Messages<'a> {
377396
buffer: &'a [u8],
@@ -474,6 +493,7 @@ impl<'a> SocketAncillary<'a> {
474493
self.length
475494
}
476495

496+
/// Returns the iterator of the control messages.
477497
#[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
478498
pub fn messages(&self) -> Messages<'_> {
479499
Messages { buffer: &self.buffer[..self.length], current: None }
@@ -552,7 +572,7 @@ impl<'a> SocketAncillary<'a> {
552572
/// The function returns `true` if there was enough space in the buffer.
553573
/// If there was not enough space then no credentials was appended.
554574
/// Technically, that means this operation adds a control message with the level `SOL_SOCKET`
555-
/// and type `SCM_CREDENTIALS`.
575+
/// and type `SCM_CREDENTIALS` or `SCM_CREDS`.
556576
///
557577
#[cfg(any(
558578
doc,

0 commit comments

Comments
 (0)