@@ -158,6 +158,7 @@ impl<'a, T> Iterator for AncillaryDataIter<'a, T> {
158
158
}
159
159
}
160
160
161
+ /// Unix credential.
161
162
#[ cfg( any(
162
163
doc,
163
164
target_os = "android" ,
@@ -191,42 +192,54 @@ pub struct UCred(libc::ucred);
191
192
target_env = "uclibc" ,
192
193
) ) ]
193
194
impl UCred {
195
+ /// Create a Unix credential struct.
196
+ ///
197
+ /// PID, UID and GID is set to 0.
194
198
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
195
199
pub fn new ( ) -> UCred {
196
200
UCred ( libc:: ucred { pid : 0 , uid : 0 , gid : 0 } )
197
201
}
198
202
203
+ /// Set the PID.
199
204
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
200
205
pub fn set_pid ( & mut self , pid : i32 ) {
201
206
self . 0 . pid = pid;
202
207
}
203
208
209
+ /// Get the current PID.
204
210
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
205
211
pub fn get_pid ( & self ) -> i32 {
206
212
self . 0 . pid
207
213
}
208
214
215
+ /// Set the UID.
209
216
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
210
217
pub fn set_uid ( & mut self , uid : u32 ) {
211
218
self . 0 . uid = uid;
212
219
}
213
220
221
+ /// Get the current UID.
214
222
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
215
223
pub fn get_uid ( & self ) -> u32 {
216
224
self . 0 . uid
217
225
}
218
226
227
+ /// Set the GID.
219
228
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
220
229
pub fn set_gid ( & mut self , gid : u32 ) {
221
230
self . 0 . gid = gid;
222
231
}
223
232
233
+ /// Get the current GID.
224
234
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
225
235
pub fn get_gid ( & self ) -> u32 {
226
236
self . 0 . gid
227
237
}
228
238
}
229
239
240
+ /// This control message contains file descriptors.
241
+ ///
242
+ /// The level is equal to `SOL_SOCKET` and the type is equal to `SCM_RIGHTS`.
230
243
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
231
244
pub struct ScmRights < ' a > ( AncillaryDataIter < ' a , RawFd > ) ;
232
245
@@ -239,6 +252,9 @@ impl<'a> Iterator for ScmRights<'a> {
239
252
}
240
253
}
241
254
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`.
242
258
#[ cfg( any(
243
259
doc,
244
260
target_os = "android" ,
@@ -279,13 +295,15 @@ impl<'a> Iterator for ScmCredentials<'a> {
279
295
}
280
296
}
281
297
298
+ /// The error type which is returned from parsing the type a control message.
282
299
#[ non_exhaustive]
283
300
#[ derive( Debug ) ]
284
301
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
285
302
pub enum AncillaryError {
286
303
Unknown { cmsg_level : i32 , cmsg_type : i32 } ,
287
304
}
288
305
306
+ /// This enum represent one control message of variable type.
289
307
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
290
308
pub enum AncillaryData < ' a > {
291
309
ScmRights ( ScmRights < ' a > ) ,
@@ -372,6 +390,7 @@ impl<'a> AncillaryData<'a> {
372
390
}
373
391
}
374
392
393
+ /// This struct is used to iterate through the control messages.
375
394
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
376
395
pub struct Messages < ' a > {
377
396
buffer : & ' a [ u8 ] ,
@@ -474,6 +493,7 @@ impl<'a> SocketAncillary<'a> {
474
493
self . length
475
494
}
476
495
496
+ /// Returns the iterator of the control messages.
477
497
#[ unstable( feature = "unix_socket_ancillary_data" , issue = "none" ) ]
478
498
pub fn messages ( & self ) -> Messages < ' _ > {
479
499
Messages { buffer : & self . buffer [ ..self . length ] , current : None }
@@ -552,7 +572,7 @@ impl<'a> SocketAncillary<'a> {
552
572
/// The function returns `true` if there was enough space in the buffer.
553
573
/// If there was not enough space then no credentials was appended.
554
574
/// 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` .
556
576
///
557
577
#[ cfg( any(
558
578
doc,
0 commit comments