Skip to content

Commit d988c65

Browse files
committed
More docs for mqueue.
Also, delete some dead code. It's always been dead.
1 parent caebe66 commit d988c65

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ feature! {
119119
))]
120120
feature! {
121121
#![feature = "mqueue"]
122-
#[allow(missing_docs)]
123122
pub mod mqueue;
124123
}
125124
feature! {

src/mqueue.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,29 @@ use crate::sys::stat::Mode;
3939
use std::mem;
4040

4141
libc_bitflags!{
42+
/// Used with [`mq_open`].
4243
pub struct MQ_OFlag: libc::c_int {
44+
/// Open the message queue for receiving messages.
4345
O_RDONLY;
46+
/// Open the queue for sending messages.
4447
O_WRONLY;
48+
/// Open the queue for both receiving and sending messages
4549
O_RDWR;
50+
/// Create a message queue.
4651
O_CREAT;
52+
/// If set along with `O_CREAT`, `mq_open` will fail if the message
53+
/// queue name exists.
4754
O_EXCL;
55+
/// `mq_send` and `mq_receive` should fail with `EAGAIN` rather than
56+
/// wait for resources that are not currently available.
4857
O_NONBLOCK;
58+
/// Set the close-on-exec flag for the message queue descriptor.
4959
O_CLOEXEC;
5060
}
5161
}
5262

53-
libc_bitflags!{
54-
pub struct FdFlag: libc::c_int {
55-
FD_CLOEXEC;
56-
}
57-
}
58-
63+
/// A message-queue attribute, optionally used with [`mq_setattr`] and
64+
/// [`mq_getattr`] and optionally [`mq_open`],
5965
#[repr(C)]
6066
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
6167
pub struct MqAttr {
@@ -72,14 +78,24 @@ pub struct MqdT(mqd_t);
7278

7379
// x32 compatibility
7480
// See https://sourceware.org/bugzilla/show_bug.cgi?id=21279
81+
/// Size of a message queue attribute member
7582
#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
7683
#[cfg_attr(docsrs, doc(cfg(all())))]
7784
pub type mq_attr_member_t = i64;
85+
/// Size of a message queue attribute member
7886
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
7987
#[cfg_attr(docsrs, doc(cfg(all())))]
8088
pub type mq_attr_member_t = libc::c_long;
8189

8290
impl MqAttr {
91+
/// Create a new message queue attribute
92+
///
93+
/// # Arguments
94+
///
95+
/// - `mq_flags`: Either `0` or `O_NONBLOCK`.
96+
/// - `mq_maxmsg`: Maximum number of messages on the queue.
97+
/// - `mq_msgsize`: Maximum message size in bytes.
98+
/// - `mq_curmsgs`: Number of messages currently in the queue.
8399
pub fn new(mq_flags: mq_attr_member_t,
84100
mq_maxmsg: mq_attr_member_t,
85101
mq_msgsize: mq_attr_member_t,
@@ -97,6 +113,7 @@ impl MqAttr {
97113
}
98114
}
99115

116+
/// The current flags, either `0` or `O_NONBLOCK`.
100117
pub const fn flags(&self) -> mq_attr_member_t {
101118
self.mq_attr.mq_flags
102119
}

0 commit comments

Comments
 (0)