From fce9a9c22b4b7d504a29882545d50c0319317162 Mon Sep 17 00:00:00 2001 From: jonay2000 Date: Thu, 8 Jun 2023 15:38:09 +0200 Subject: [PATCH 1/3] update readme --- README.md | 15 ++++++++------- src/lib.rs | 52 +--------------------------------------------------- 2 files changed, 9 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index d0818bd..44dcfb9 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,11 @@ The ringbuffer crate provides safe fixed size circular buffers (ringbuffers) in Implementations for three kinds of ringbuffers, with a mostly similar API are provided: -| type | description | -| --- | --- | -| `AllocRingBuffer` | Ringbuffer allocated on the heap at runtime. This ringbuffer is still fixed size and requires alloc. | -| `ConstGenericRingBuffer` | Ringbuffer which uses const generics to allocate on the stack. | +| type | description | +|---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `AllocRingBuffer` | Ringbuffer allocated on the heap at runtime. This ringbuffer is still fixed size. This requires alloc and the alloc feature. | +| `GrowableAllocRingBuffer` | Ringbuffer allocated on the heap at runtime. This ringbuffer can grow in size, and is implemented as an `alloc::VecDeque` internally. This requires alloc and the alloc feature. | +| `ConstGenericRingBuffer` | Ringbuffer which uses const generics to allocate on the stack. | All of these ringbuffers also implement the RingBuffer trait for their shared API surface. @@ -44,9 +45,9 @@ fn main() { # Features -| name | default | description | -| --- | --- | --- | -| alloc | ✓ | Disable this feature to remove the dependency on alloc. The feature is compatible with `no_std`. | +| name | default | description | +|-------|---------|--------------------------------------------------------------------------------------------------------------| +| alloc | ✓ | Disable this feature to remove the dependency on alloc. Disabling this feature makes `ringbuffer` `no_std`. | # License diff --git a/src/lib.rs b/src/lib.rs index 3d83655..6c61e38 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,57 +11,7 @@ #![deny(clippy::doc_markdown)] #![deny(clippy::semicolon_if_nothing_returned)] #![allow(unused_unsafe)] // to support older rust versions -//! # Ringbuffer -//! ![Github Workflows](https://img.shields.io/github/workflow/status/NULLx76/ringbuffer/Rust?logo=github&style=for-the-badge) -//! [![Codecov](https://img.shields.io/codecov/c/github/NULLx76/ringbuffer?logo=codecov&style=for-the-badge)](https://codecov.io/gh/NULLx76/ringbuffer) -//! [![Docs.rs](https://img.shields.io/badge/docs.rs-ringbuffer-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K)](https://docs.rs/ringbuffer) -//! [![Crates.io](https://img.shields.io/crates/v/ringbuffer?logo=rust&style=for-the-badge)](https://crates.io/crates/ringbuffer) -//! -//! The ringbuffer crate provides safe fixed size circular buffers (ringbuffers) in rust. -//! -//! Implementations for three kinds of ringbuffers, with a mostly similar API are provided: -//! -//! | type | description | -//! | --- | --- | -//! | [`AllocRingBuffer`] | Ringbuffer allocated on the heap at runtime. This ringbuffer is still fixed size and requires alloc. | -//! | [`ConstGenericRingBuffer`] | Ringbuffer which uses const generics to allocate on the stack. | -//! -//! All of these ringbuffers also implement the [`RingBuffer`] trait for their shared API surface. -//! -//! # Usage -//! -//! ``` -//! use ringbuffer::{AllocRingBuffer, RingBuffer, RingBufferExt, RingBufferWrite}; -//! -//! let mut buffer = AllocRingBuffer::with_capacity(2); -//! -//! // First entry of the buffer is now 5. -//! buffer.push(5); -//! -//! // The last item we pushed is 5 -//! assert_eq!(buffer.get(-1), Some(&5)); -//! -//! // Second entry is now 42. -//! buffer.push(42); -//! -//! assert_eq!(buffer.peek(), Some(&5)); -//! assert!(buffer.is_full()); -//! -//! // Because capacity is reached the next push will be the first item of the buffer. -//! buffer.push(1); -//! assert_eq!(buffer.to_vec(), vec![42, 1]); -//! -//! ``` -//! -//! # Features -//! -//! | name | default | description | -//! | --- | --- | --- | -//! | alloc | ✓ | Disable this feature to remove the dependency on alloc. Useful for kernels. | -//! -//! # License -//! -//! Licensed under the MIT License +#![doc = include_str!("../README.md")] #[cfg(feature = "alloc")] extern crate alloc; From 4d76a131b53dabe53c782123339f648c88cd1fb0 Mon Sep 17 00:00:00 2001 From: jonay2000 Date: Thu, 8 Jun 2023 15:40:07 +0200 Subject: [PATCH 2/3] fix doctest in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44dcfb9..6b2184d 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ MSRV: Rust 1.59 # Usage ```rust -use ringbuffer::{AllocRingBuffer, RingBuffer}; +use ringbuffer::{AllocRingBuffer, RingBuffer, RingBufferExt, RingBufferWrite}; fn main() { let mut buffer = AllocRingBuffer::with_capacity(2); From 1cc5cf5a16631ddf0f3497a78b1715ad60565c07 Mon Sep 17 00:00:00 2001 From: jonay2000 Date: Thu, 8 Jun 2023 15:44:24 +0200 Subject: [PATCH 3/3] fix badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b2184d..acb4c6d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Ringbuffer -![Github Workflows](https://img.shields.io/github/actions/workflow/status/NULLx76/ringbuffer/rust.yml?branch=master&logo=github&style=for-the-badge) +![Github Workflows](https://img.shields.io/github/actions/workflow/status/NULLx76/ringbuffer/rust.yml?style=for-the-badge) [![Docs.rs](https://img.shields.io/badge/docs.rs-ringbuffer-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K)](https://docs.rs/ringbuffer) [![Crates.io](https://img.shields.io/crates/v/ringbuffer?logo=rust&style=for-the-badge)](https://crates.io/crates/ringbuffer)