Skip to content

Commit c77a872

Browse files
Merge #1619
1619: Added getters for the MqAttr struct r=rtzoeller a=fpagliughi With the existing code, if you call `mq_getattr()`, there does not appear to be a way to get any of the attributes from the returned `MqAttr` struct, other than the flags. This adds getter functions to retrieve the size parameters of the queue, and the current number of messages in the queue. Co-authored-by: fpagliughi <[email protected]>
2 parents 2043bce + 80f447b commit c77a872

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
2323
(#[1621](https://github.com/nix-rust/nix/pull/1621))
2424
- Added the `SO_TIMESTAMPING` support
2525
(#[1547](https://github.com/nix-rust/nix/pull/1547))
26+
- Added getter methods to `MqAttr` struct
27+
(#[1619](https://github.com/nix-rust/nix/pull/1619))
2628

2729
### Changed
2830
### Fixed

src/mqueue.rs

+15
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ impl MqAttr {
6464
pub const fn flags(&self) -> mq_attr_member_t {
6565
self.mq_attr.mq_flags
6666
}
67+
68+
/// The max number of messages that can be held by the queue
69+
pub const fn maxmsg(&self) -> mq_attr_member_t {
70+
self.mq_attr.mq_maxmsg
71+
}
72+
73+
/// The maximum size of each message (in bytes)
74+
pub const fn msgsize(&self) -> mq_attr_member_t {
75+
self.mq_attr.mq_msgsize
76+
}
77+
78+
/// The number of messages currently held in the queue
79+
pub const fn curmsgs(&self) -> mq_attr_member_t {
80+
self.mq_attr.mq_curmsgs
81+
}
6782
}
6883

6984

0 commit comments

Comments
 (0)