Skip to content

Commit

Permalink
Flat container storage abstraction
Browse files Browse the repository at this point in the history
Signed-off-by: Moritz Hoffmann <[email protected]>
  • Loading branch information
antiguru committed Jul 2, 2024
1 parent 121a9a8 commit 86810a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion container/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ license = "MIT"

[dependencies]
columnation = { git = "https://github.com/frankmcsherry/columnation" }
flatcontainer = "0.5"
# flatcontainer = "0.5"
flatcontainer = { git = "https://github.com/antiguru/flatcontainer", branch = "storage" }
serde = { version = "1.0"}
16 changes: 14 additions & 2 deletions container/src/flatcontainer.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
//! Present a [`FlatStack`] as a timely container.

pub use flatcontainer::*;
use flatcontainer::impls::offsets::OffsetContainer;
use crate::{buffer, Container, SizableContainer, PushInto};

impl<R: Region + Clone + 'static> Container for FlatStack<R> {
impl<R, S> Container for FlatStack<R, S>
where
R: Region + Clone + 'static,
S: OffsetContainer<<R as Region>::Index> + Clone + 'static,
for<'a> &'a S: IntoIterator<Item = &'a R::Index>,
{
type ItemRef<'a> = R::ReadItem<'a> where Self: 'a;
type Item<'a> = R::ReadItem<'a> where Self: 'a;

Expand All @@ -28,6 +34,7 @@ impl<R: Region + Clone + 'static> Container for FlatStack<R> {
}
}

// Only implemented for `FlatStack` with `Vec` offsets.
impl<R: Region + Clone + 'static> SizableContainer for FlatStack<R> {
fn capacity(&self) -> usize {
self.capacity()
Expand All @@ -42,7 +49,12 @@ impl<R: Region + Clone + 'static> SizableContainer for FlatStack<R> {
}
}

impl<R: Region + Push<T>, T> PushInto<T> for FlatStack<R> {
impl<R, S, T> PushInto<T> for FlatStack<R, S>
where
R: Region + Push<T>,
S: OffsetContainer<R::Index> + Clone + 'static,
for<'a> &'a S: IntoIterator<Item = &'a R::Index>,
{
#[inline]
fn push_into(&mut self, item: T) {
self.copy(item);
Expand Down

0 comments on commit 86810a5

Please sign in to comment.