dope_core/driver/route/table/
slab.rs1use o3::alloc;
2use table::borrows;
3
4use crate::driver::{route, route::table};
5
6#[repr(transparent)]
7pub struct Slab<T, Tag: route::Tag> {
8 inner: table::Storage<T, Tag>,
9}
10
11impl<T, Tag: route::Tag> Slab<T, Tag> {
12 pub fn try_new(cap: table::Capacity) -> Result<Self, alloc::Error> {
14 Ok(Self {
15 inner: table::Storage::try_new(cap.0)?,
16 })
17 }
18
19 pub fn view(&self) -> borrows::View<'_, T, Tag> {
20 borrows::View::new(&self.inner)
21 }
22
23 pub fn access(&mut self) -> borrows::Access<'_, T, Tag> {
24 borrows::Access::new(&mut self.inner)
25 }
26
27 pub fn vacancy(&mut self) -> borrows::Vacancy<'_, T, Tag> {
28 borrows::Vacancy::new(&mut self.inner)
29 }
30}