Expand description
Types to define how data is stored in a queue.
To access data in an asyncio
, blocking
or nonblocking
queue, the backing buffer must
implement the Storage
trait. This trait acts as an unsafe building block to access
multiple mutable regions in a buffer, which each queue builds on to provide safe abstractions.
Two standard storage types are available out of the box:
HeapBuffer
stores a contiguous array of items on the heap. This means the buffer can have a size chosen at runtime and is cheaper to move, with the possible downside of requiring an allocator.StackBuffer
stores a contiguous array of items on the stack. As a result, it has a fixed size at compile-time and can be expensive to move but is extremely cheap to create.
Note: all queues currently move their buffers to the heap when constructed.
§Examples
Creating a queue from a heap-allocated buffer:
use mini_io_queue::blocking;
use mini_io_queue::storage::HeapBuffer;
let buffer: HeapBuffer<u8> = HeapBuffer::new(100);
let (reader, writer) = blocking::queue_from(buffer);
Creating a queue from a stack-allocated buffer:
use mini_io_queue::blocking;
use mini_io_queue::storage::StackBuffer;
let buffer: StackBuffer<u8, 100> = StackBuffer::default();
let (reader, writer) = blocking::queue_from(buffer);
Structs§
- Heap
Buffer heap-buffer
- Backing buffer for a queue, allocated on the heap.
- Stack
Buffer stack-buffer
- Backing buffer for a queue, allocated on the stack.
Traits§
- Storage
- Storage for a contiguous array of items allowing mutable access to multiple ranges as long as they don’t overlap.