Skip to content

Commit

Permalink
Merge pull request #22 from earthstar-project/successors
Browse files Browse the repository at this point in the history
Path Successors [✨ surprises ✨]
  • Loading branch information
sgwilym authored Jul 3, 2024
2 parents 6fedd72 + d2ba08d commit 3e771d0
Show file tree
Hide file tree
Showing 19 changed files with 778 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/target
**/target
108 changes: 104 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]

members = ["data-model"]
members = ["data-model", "fuzz"]
resolver = "2"

116 changes: 116 additions & 0 deletions data-model/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion data-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ version = "0.1.0"
edition = "2021"

[dependencies]
bytes = "1.4"
arbitrary = { version = "1.0.2", features = ["derive"]}
6 changes: 5 additions & 1 deletion data-model/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ mod tests {

#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone)]
struct FakeSubspaceId(usize);
impl SubspaceId for FakeSubspaceId {}
impl SubspaceId for FakeSubspaceId {
fn successor(&self) -> Option<Self> {
Some(FakeSubspaceId(self.0 + 1))
}
}

#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone)]
struct FakePayloadDigest(usize);
Expand Down
8 changes: 6 additions & 2 deletions data-model/src/grouping/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
path::Path,
};

use super::{range::Range, range_3d::Range3d};
use super::range::Range;

/// The possible values of an [`Area`]'s `subspace`.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
Expand Down Expand Up @@ -112,7 +112,11 @@ mod tests {

#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Clone)]
struct FakeSubspaceId(usize);
impl SubspaceId for FakeSubspaceId {}
impl SubspaceId for FakeSubspaceId {
fn successor(&self) -> Option<Self> {
Some(FakeSubspaceId(self.0 + 1))
}
}

#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone)]
struct FakePayloadDigest(usize);
Expand Down
6 changes: 5 additions & 1 deletion data-model/src/grouping/range_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ mod tests {

#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone, Debug)]
struct FakeSubspaceId(usize);
impl SubspaceId for FakeSubspaceId {}
impl SubspaceId for FakeSubspaceId {
fn successor(&self) -> Option<Self> {
Some(FakeSubspaceId(self.0 + 1))
}
}

#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone)]
struct FakePayloadDigest(usize);
Expand Down
6 changes: 5 additions & 1 deletion data-model/src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ pub trait NamespaceId: Eq + Default + Clone {}
/// ## Implementation notes
///
/// The [`Default`] implementation **must** return the least element in the total order of [`SubspaceId`].
pub trait SubspaceId: Ord + Default + Clone {}
pub trait SubspaceId: Ord + Default + Clone {
/// Return the next possible value in the set of all [`SubspaceId`].
/// e.g. the successor of 3 is 4.
fn successor(&self) -> Option<Self>;
}

/// A totally ordered type for [content-addressing](https://en.wikipedia.org/wiki/Content_addressing) the data that Willow stores.
/// [Definition](https://willowprotocol.org/specs/data-model/index.html#PayloadDigest).
Expand Down
Loading

0 comments on commit 3e771d0

Please sign in to comment.