Skip to content

Commit

Permalink
Merge pull request #34 from earthstar-project/repackaging
Browse files Browse the repository at this point in the history
Repackaging
  • Loading branch information
sgwilym authored Aug 6, 2024
2 parents 5f063e5 + fc65876 commit 1194c22
Show file tree
Hide file tree
Showing 76 changed files with 287 additions and 255 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

4 changes: 2 additions & 2 deletions data-model/src/encoding/compact_width.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ pub mod encoding {

use crate::encoding::unsigned_int::{U16BE, U32BE, U64BE, U8BE};

#[syncify_replace(use crate::encoding::parameters_sync::{Decodable, };)]
use crate::encoding::parameters::Decodable;
#[syncify_replace(use crate::encoding::sync::{Decodable};)]
use crate::encoding::Decodable;

/// Encode a `u64` integer as a `compact_width(value)`-byte big-endian integer, and consume that with a [`BulkConsumer`].
pub async fn encode_compact_width_be<Consumer: BulkConsumer<Item = u8>>(
Expand Down
41 changes: 29 additions & 12 deletions data-model/src/encoding/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
pub mod bytes;
pub mod compact_width;
pub mod error;
pub mod parameters;
pub mod parameters_sync;
pub mod relativity;
mod bytes;
mod compact_width;
mod error;
mod max_power;
mod traits_sync;
mod unsigned_int;

pub use bytes::encoding::produce_byte;
pub use bytes::is_bitflagged;

pub use compact_width::encoding::*;
pub use compact_width::CompactWidth;

pub use error::*;

mod traits;
pub use traits::*;

mod relativity;

pub(crate) mod shared_buffers;
pub mod unsigned_int;

pub mod max_power;
pub mod max_power_sync {
use super::max_power;
pub use max_power::encoding_sync::*;
pub use max_power::max_power;
pub use unsigned_int::*;

pub use max_power::{decode_max_power, encode_max_power, max_power};

pub mod sync {
pub use super::bytes::encoding_sync::produce_byte;
pub use super::compact_width::encoding_sync::*;
pub use super::max_power::encoding_sync::*;
pub use super::traits_sync::*;
}
12 changes: 4 additions & 8 deletions data-model/src/encoding/relativity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ pub(super) mod encoding {
#[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)]
use ufotofu::local_nb::{BulkConsumer, BulkProducer};

#[syncify_replace(use crate::encoding::parameters_sync::{Encodable, Decodable, RelativeDecodable, RelativeEncodable};)]
use crate::encoding::parameters::{Decodable, Encodable, RelativeDecodable, RelativeEncodable};
#[syncify_replace(use crate::encoding::sync::{Encodable, Decodable, RelativeDecodable, RelativeEncodable};)]
use crate::encoding::{Decodable, Encodable, RelativeDecodable, RelativeEncodable};

#[syncify_replace(use crate::encoding::max_power_sync::{decode_max_power, encode_max_power};)]
#[syncify_replace(use crate::encoding::sync::{decode_max_power, encode_max_power};)]
use crate::encoding::max_power::{decode_max_power, encode_max_power};

#[syncify_replace(use crate::encoding::compact_width::encoding_sync::{ decode_compact_width_be, encode_compact_width_be};)]
Expand All @@ -30,11 +30,7 @@ pub(super) mod encoding {
shared_buffers::ScratchSpacePathDecoding,
},
entry::Entry,
grouping::{
area::{Area, AreaSubspace},
range::{Range, RangeEnd},
range_3d::Range3d,
},
grouping::{Area, AreaSubspace, Range, Range3d, RangeEnd},
parameters::{NamespaceId, PayloadDigest, SubspaceId},
path::Path,
};
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions data-model/src/encoding/unsigned_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ mod encoding {
#[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)]
use ufotofu::local_nb::{BulkConsumer, BulkProducer};

#[syncify_replace(use crate::encoding::parameters_sync::{Decodable, Encodable};)]
use crate::encoding::parameters::{Decodable, Encodable};
#[syncify_replace(use crate::encoding::sync::{Decodable, Encodable};)]
use crate::encoding::{Decodable, Encodable};

impl Encodable for U8BE {
async fn encode<Consumer>(&self, consumer: &mut Consumer) -> Result<(), Consumer::Error>
Expand Down
6 changes: 3 additions & 3 deletions data-model/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use arbitrary::size_hint::and_all;
use arbitrary::Arbitrary;

use crate::{
encoding::{error::DecodeError, unsigned_int::U64BE},
encoding::{DecodeError, U64BE},
parameters::{IsAuthorisedWrite, NamespaceId, PayloadDigest, SubspaceId},
path::Path,
};
Expand Down Expand Up @@ -121,8 +121,8 @@ mod encoding {
#[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)]
use ufotofu::local_nb::{BulkConsumer, BulkProducer};

#[syncify_replace(use crate::encoding::parameters_sync::{Decodable, Encodable};)]
use crate::encoding::parameters::{Decodable, Encodable};
#[syncify_replace(use crate::encoding::sync::{Decodable, Encodable};)]
use crate::encoding::{Decodable, Encodable};

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Encodable
for Entry<MCL, MCC, MPL, N, S, PD>
Expand Down
12 changes: 8 additions & 4 deletions data-model/src/grouping/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
pub mod area;
pub mod area_of_interest;
pub mod range;
pub mod range_3d;
mod area;
pub use area::*;
mod area_of_interest;
pub use area_of_interest::*;
mod range;
pub use range::*;
mod range_3d;
pub use range_3d::*;
13 changes: 10 additions & 3 deletions data-model/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Allo!
#![feature(
new_uninit,
async_fn_traits,
Expand All @@ -8,7 +10,12 @@
)]

pub mod encoding;
pub mod entry;
mod entry;
pub use entry::*;
pub mod grouping;
pub mod parameters;
pub mod path;

mod parameters;
pub use parameters::*;

mod path;
pub use path::*;
12 changes: 6 additions & 6 deletions data-model/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,16 +787,16 @@ use syncify::syncify_replace;
mod encoding {
use super::*;

use crate::encoding::{error::DecodeError, shared_buffers::ScratchSpacePathDecoding};
use crate::encoding::{shared_buffers::ScratchSpacePathDecoding, DecodeError};

#[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)]
use ufotofu::local_nb::{BulkConsumer, BulkProducer};

#[syncify_replace(use crate::encoding::parameters_sync::{Decodable, Encodable};)]
use crate::encoding::parameters::{Decodable, Encodable};
#[syncify_replace(use crate::encoding::sync::{Decodable, Encodable};)]
use crate::encoding::{Decodable, Encodable};

#[syncify_replace(use crate::encoding::max_power_sync::{decode_max_power, encode_max_power};)]
use crate::encoding::max_power::{decode_max_power, encode_max_power};
#[syncify_replace(use crate::encoding::sync::{decode_max_power, encode_max_power};)]
use crate::encoding::{decode_max_power, encode_max_power};

impl<const MCL: usize, const MCC: usize, const MPL: usize> Encodable for Path<MCL, MCC, MPL> {
async fn encode<C>(&self, consumer: &mut C) -> Result<(), C::Error>
Expand Down Expand Up @@ -935,7 +935,7 @@ impl<'a, const MCL: usize, const MCC: usize, const MPL: usize> Arbitrary<'a>
/// Like core::iter::Chain, but implements ExactSizeIter if both components implement it. Panics if the resulting length overflows.
///
/// Code liberally copy-pasted from the standard library.
pub struct ExactLengthChain<A, B> {
struct ExactLengthChain<A, B> {
a: Option<A>,
b: Option<B>,
}
Expand Down
5 changes: 1 addition & 4 deletions earthstar/src/cinn25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ use arbitrary::{
};
use either::Either;
use ufotofu::local_nb::{BulkConsumer, BulkProducer};
use willow_data_model::encoding::{
error::DecodeError,
parameters::{Decodable, Encodable},
};
use willow_data_model::encoding::{Decodable, DecodeError, Encodable};

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Shortname<const MIN_LENGTH: usize, const MAX_LENGTH: usize>(pub Vec<u8>);
Expand Down
7 changes: 2 additions & 5 deletions earthstar/src/identity_id.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use arbitrary::Arbitrary;
use ufotofu::local_nb::{BulkConsumer, BulkProducer};
use willow_data_model::{
encoding::{
error::DecodeError,
parameters::{Decodable, Encodable},
},
parameters::SubspaceId,
encoding::{Decodable, DecodeError, Encodable},
SubspaceId,
};

use crate::cinn25519::{Cinn25519PublicKey, Shortname};
Expand Down
7 changes: 2 additions & 5 deletions earthstar/src/namespace_id.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use arbitrary::Arbitrary;
use ufotofu::local_nb::{BulkConsumer, BulkProducer};
use willow_data_model::{
encoding::{
error::DecodeError,
parameters::{Decodable, Encodable},
},
parameters::NamespaceId,
encoding::{Decodable, DecodeError, Encodable},
NamespaceId,
};

use crate::cinn25519::{Cinn25519PublicKey, Shortname};
Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "willow-data-model-fuzz"
name = "willow-fuzz"
version = "0.0.0"
publish = false
edition = "2021"
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/area_rel_area_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use earthstar::identity_id::IdentityIdentifier as IdentityId;
use libfuzzer_sys::fuzz_target;
use ufotofu::local_nb::consumer::TestConsumer;
use willow_data_model::grouping::area::Area;
use willow_data_model_fuzz::encode::relative_encoding_roundtrip;
use willow_data_model::grouping::Area;
use willow_fuzz::encode::relative_encoding_roundtrip;

fuzz_target!(|data: (
Area<16, 16, 16, IdentityId>,
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/area_rel_area_encoding_random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use earthstar::identity_id::IdentityIdentifier as IdentityId;
use libfuzzer_sys::fuzz_target;
use willow_data_model::grouping::area::Area;
use willow_data_model_fuzz::encode::relative_encoding_random_less_strict;
use willow_data_model::grouping::Area;
use willow_fuzz::encode::relative_encoding_random_less_strict;

fuzz_target!(|data: (&[u8], Area<16, 16, 16, IdentityId>)| {
// fuzzed code goes here
Expand Down
6 changes: 3 additions & 3 deletions fuzz/fuzz_targets/entry_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId;
use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId;
use libfuzzer_sys::fuzz_target;
use ufotofu::local_nb::consumer::TestConsumer;
use willow_data_model::entry::Entry;
use willow_data_model_fuzz::encode::encoding_roundtrip;
use willow_data_model_fuzz::placeholder_params::FakePayloadDigest;
use willow_data_model::Entry;
use willow_fuzz::encode::encoding_roundtrip;
use willow_fuzz::placeholder_params::FakePayloadDigest;

fuzz_target!(|data: (
Entry<3, 3, 3, EsNamespaceId, IdentityId, FakePayloadDigest>,
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/entry_encoding_random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
use earthstar::identity_id::IdentityIdentifier as IdentityId;
use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId;

use willow_data_model::entry::Entry;
use willow_data_model::Entry;

use libfuzzer_sys::fuzz_target;
use willow_data_model_fuzz::{encode::encoding_random, placeholder_params::FakePayloadDigest};
use willow_fuzz::{encode::encoding_random, placeholder_params::FakePayloadDigest};

fuzz_target!(|data: &[u8]| {
smol::block_on(async {
Expand Down
6 changes: 3 additions & 3 deletions fuzz/fuzz_targets/entry_rel_entry_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId;
use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId;
use libfuzzer_sys::fuzz_target;
use ufotofu::local_nb::consumer::TestConsumer;
use willow_data_model::entry::Entry;
use willow_data_model_fuzz::encode::relative_encoding_roundtrip;
use willow_data_model_fuzz::placeholder_params::FakePayloadDigest;
use willow_data_model::Entry;
use willow_fuzz::encode::relative_encoding_roundtrip;
use willow_fuzz::placeholder_params::FakePayloadDigest;

fuzz_target!(|data: (
Entry<16, 16, 16, EsNamespaceId, IdentityId, FakePayloadDigest>,
Expand Down
6 changes: 3 additions & 3 deletions fuzz/fuzz_targets/entry_rel_entry_encoding_random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
use earthstar::identity_id::IdentityIdentifier as IdentityId;
use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId;
use libfuzzer_sys::fuzz_target;
use willow_data_model::entry::Entry;
use willow_data_model_fuzz::encode::relative_encoding_random_less_strict;
use willow_data_model_fuzz::placeholder_params::FakePayloadDigest;
use willow_data_model::Entry;
use willow_fuzz::encode::relative_encoding_random_less_strict;
use willow_fuzz::placeholder_params::FakePayloadDigest;

fuzz_target!(|data: (
&[u8],
Expand Down
8 changes: 4 additions & 4 deletions fuzz/fuzz_targets/entry_rel_namespace_area_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId;
use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId;
use libfuzzer_sys::fuzz_target;
use ufotofu::local_nb::consumer::TestConsumer;
use willow_data_model::entry::Entry;
use willow_data_model::grouping::area::Area;
use willow_data_model_fuzz::encode::relative_encoding_roundtrip;
use willow_data_model_fuzz::placeholder_params::FakePayloadDigest;
use willow_data_model::grouping::Area;
use willow_data_model::Entry;
use willow_fuzz::encode::relative_encoding_roundtrip;
use willow_fuzz::placeholder_params::FakePayloadDigest;

fuzz_target!(|data: (
Entry<16, 16, 16, EsNamespaceId, IdentityId, FakePayloadDigest>,
Expand Down
8 changes: 4 additions & 4 deletions fuzz/fuzz_targets/entry_rel_namespace_area_encoding_random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
use earthstar::identity_id::IdentityIdentifier as IdentityId;
use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId;
use libfuzzer_sys::fuzz_target;
use willow_data_model::entry::Entry;
use willow_data_model::grouping::area::Area;
use willow_data_model_fuzz::encode::relative_encoding_random_less_strict;
use willow_data_model_fuzz::placeholder_params::FakePayloadDigest;
use willow_data_model::grouping::Area;
use willow_data_model::Entry;
use willow_fuzz::encode::relative_encoding_random_less_strict;
use willow_fuzz::placeholder_params::FakePayloadDigest;

fuzz_target!(
|data: (&[u8], (EsNamespaceId, Area<16, 16, 16, IdentityId>))| {
Expand Down
8 changes: 4 additions & 4 deletions fuzz/fuzz_targets/entry_rel_namespace_range_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use earthstar::identity_id::IdentityIdentifier as IdentityId;
use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId;
use libfuzzer_sys::fuzz_target;
use ufotofu::local_nb::consumer::TestConsumer;
use willow_data_model::entry::Entry;
use willow_data_model::grouping::range_3d::Range3d;
use willow_data_model_fuzz::encode::relative_encoding_roundtrip;
use willow_data_model_fuzz::placeholder_params::FakePayloadDigest;
use willow_data_model::grouping::Range3d;
use willow_data_model::Entry;
use willow_fuzz::encode::relative_encoding_roundtrip;
use willow_fuzz::placeholder_params::FakePayloadDigest;

fuzz_target!(|data: (
Entry<16, 16, 16, EsNamespaceId, IdentityId, FakePayloadDigest>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
use earthstar::identity_id::IdentityIdentifier as IdentityId;
use earthstar::namespace_id::NamespaceIdentifier as EsNamespaceId;
use libfuzzer_sys::fuzz_target;
use willow_data_model::entry::Entry;
use willow_data_model::grouping::range_3d::Range3d;
use willow_data_model_fuzz::encode::relative_encoding_random_less_strict;
use willow_data_model_fuzz::placeholder_params::FakePayloadDigest;
use willow_data_model::grouping::Range3d;
use willow_data_model::Entry;
use willow_fuzz::encode::relative_encoding_random_less_strict;
use willow_fuzz::placeholder_params::FakePayloadDigest;

fuzz_target!(
|data: (&[u8], (EsNamespaceId, Range3d<16, 16, 16, IdentityId>))| {
Expand Down
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/mc_capability_append_delegation.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![no_main]

use libfuzzer_sys::fuzz_target;
use meadowcap::{mc_capability::McCapability, Delegation, InvalidDelegationError};
use willow_data_model_fuzz::silly_sigs::{SillyPublicKey, SillySig};
use meadowcap::{Delegation, InvalidDelegationError, McCapability};
use willow_fuzz::silly_sigs::{SillyPublicKey, SillySig};

fuzz_target!(|data: (
Delegation<16, 16, 16, SillyPublicKey, SillySig>,
Expand Down
6 changes: 3 additions & 3 deletions fuzz/fuzz_targets/mc_capability_delegation.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![no_main]

use libfuzzer_sys::fuzz_target;
use meadowcap::{mc_capability::McCapability, FailedDelegationError};
use willow_data_model::grouping::area::Area;
use willow_data_model_fuzz::silly_sigs::{SillyPublicKey, SillySecret, SillySig};
use meadowcap::{FailedDelegationError, McCapability};
use willow_data_model::grouping::Area;
use willow_fuzz::silly_sigs::{SillyPublicKey, SillySecret, SillySig};

fuzz_target!(|data: (
SillySecret,
Expand Down
Loading

0 comments on commit 1194c22

Please sign in to comment.