Skip to content

Commit

Permalink
Merge #1619
Browse files Browse the repository at this point in the history
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 <fpagliughi@mindspring.com>
  • Loading branch information
bors[bot] and fpagliughi authored Dec 28, 2021
2 parents 2043bce + 80f447b commit c77a872
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
(#[1621](https://github.com/nix-rust/nix/pull/1621))
- Added the `SO_TIMESTAMPING` support
(#[1547](https://github.com/nix-rust/nix/pull/1547))
- Added getter methods to `MqAttr` struct
(#[1619](https://github.com/nix-rust/nix/pull/1619))

### Changed
### Fixed
Expand Down
15 changes: 15 additions & 0 deletions src/mqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ impl MqAttr {
pub const fn flags(&self) -> mq_attr_member_t {
self.mq_attr.mq_flags
}

/// The max number of messages that can be held by the queue
pub const fn maxmsg(&self) -> mq_attr_member_t {
self.mq_attr.mq_maxmsg
}

/// The maximum size of each message (in bytes)
pub const fn msgsize(&self) -> mq_attr_member_t {
self.mq_attr.mq_msgsize
}

/// The number of messages currently held in the queue
pub const fn curmsgs(&self) -> mq_attr_member_t {
self.mq_attr.mq_curmsgs
}
}


Expand Down

0 comments on commit c77a872

Please sign in to comment.