about summary refs log tree commit diff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2017-10-16T15·43+0200
committerVincent Ambo <tazjin@gmail.com>2017-10-16T15·43+0200
commit1b7464f9cff886ba397e1335a0e50d7e45860a5a (patch)
treeb4c38aac766504a11e09c9b16e1b50d8f5e99214 /src/lib.rs
parentb75306e58fad9f4456e141436205ce0a4caa00e8 (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.rs10
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,
         )?;