From a29aa7971db6f1fbb4840ba2ae14be534eb186e9 Mon Sep 17 00:00:00 2001 From: finga Date: Fri, 8 Dec 2023 01:20:38 +0100 Subject: [PATCH] readme: Add an example to the readme --- sysvmq/README.md | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sysvmq/README.md b/sysvmq/README.md index 3f1e561..aef2938 100644 --- a/sysvmq/README.md +++ b/sysvmq/README.md @@ -1,9 +1,19 @@ # Sysvmq -This aims to be a easy usable API for SysV IPC message queues. +This library provides a convenient and easy usable API for SysV IPC +message queues. - Note: This library is work in progress. +```rust +use sysvmq::{SysvMq, SysvMqError}; -Currently supported operations are only `create` and `unlink`. The -`create` operation creates a SysV IPC message queue and the `unlink` -operation deletes such a SysV IPC message queue. +fn example() -> Result<(), SysvMqError> { + let mut mq = SysvMq::new(0)?; + let mut buf = [0u8; 11]; + + mq.send(b"hello queue")?; + mq.recv(&mut buf)?; + mq.delete()?; + + Ok(()) +} +```