o3 0.9.0

shared-nothing primitives
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use o3::buffer::{BLOCK_CAPACITY, FixedPoolCapacity, Pool};
use o3::collections::IndexedMinHeap;
use o3::collections::Slab;

fn main() {
    let mut connections: Slab<&str> = Slab::with_capacity(64);
    let connection = connections.insert("ready").unwrap();
    assert_eq!(connections.get(connection), Some(&"ready"));

    let mut deadlines = IndexedMinHeap::with_capacity(64);
    deadlines.insert(connection, 10).unwrap();
    assert_eq!(deadlines.pop(), Some((connection, 10)));

    let buffers = Pool::<FixedPoolCapacity<BLOCK_CAPACITY>>::new(8);
    let mut buffer = buffers.try_acquire().unwrap();
    buffer.try_extend_from_slice(b"response").unwrap();
    assert_eq!(buffer.as_ref(), b"response");
}