diff options
author | Vincent Ambo <tazjin@gmail.com> | 2017-10-16T15·43+0200 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2017-10-16T15·43+0200 |
commit | 1b7464f9cff886ba397e1335a0e50d7e45860a5a (patch) | |
tree | b4c38aac766504a11e09c9b16e1b50d8f5e99214 /src/lib.rs | |
parent | b75306e58fad9f4456e141436205ce0a4caa00e8 (diff) |
refactor(lib): Add some additional documentation
* improve delete() docs * add docs for send() & receive() * remove unnecessary clone() calls
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs index 75846a6dee91..6cb595a4d68a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -181,31 +181,35 @@ impl Queue { } /// Delete a message queue from the system. This method will make the queue unavailable for - /// other processes, too! + /// other processes after their current queue descriptors have been closed. pub fn delete(self) -> Result<(), Error> { mqueue::mq_unlink(&self.name.0)?; drop(self); Ok(()) } + /// Send a message to the message queue. + /// If the queue is full this call will block until a message has been consumed. pub fn send(&self, msg: &Message) -> Result<(), Error> { if msg.data.len() > self.max_size as usize { return Err(Error::MessageSizeExceeded()); } mqueue::mq_send( - self.queue_descriptor.clone(), + self.queue_descriptor, msg.data.as_ref(), msg.priority, ).map_err(|e| e.into()) } + /// Receive a message from the message queue. + /// If the queue is empty this call will block until a message arrives. pub fn receive(&self) -> Result<Message, Error> { let mut data: Vec<u8> = vec![0; self.max_size as usize]; let mut priority: u32 = 0; let msg_size = mqueue::mq_receive( - self.queue_descriptor.clone(), + self.queue_descriptor, data.as_mut(), &mut priority, )?; |