diff --git a/data-model/src/encoding/compact_width.rs b/data-model/src/encoding/compact_width.rs index 2018bca..0a2f331 100644 --- a/data-model/src/encoding/compact_width.rs +++ b/data-model/src/encoding/compact_width.rs @@ -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>( diff --git a/data-model/src/encoding/mod.rs b/data-model/src/encoding/mod.rs index 96339c2..d67a710 100644 --- a/data-model/src/encoding/mod.rs +++ b/data-model/src/encoding/mod.rs @@ -1,20 +1,32 @@ -pub mod bytes; -pub mod compact_width; -/* +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::*; -*/ -pub mod error; -pub mod parameters; -pub mod parameters_sync; -pub mod relativity; -// mod relativity; + +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::*; } diff --git a/data-model/src/encoding/relativity.rs b/data-model/src/encoding/relativity.rs index d9ebe29..eaaeb0c 100644 --- a/data-model/src/encoding/relativity.rs +++ b/data-model/src/encoding/relativity.rs @@ -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};)] diff --git a/data-model/src/encoding/parameters.rs b/data-model/src/encoding/traits.rs similarity index 100% rename from data-model/src/encoding/parameters.rs rename to data-model/src/encoding/traits.rs diff --git a/data-model/src/encoding/parameters_sync.rs b/data-model/src/encoding/traits_sync.rs similarity index 100% rename from data-model/src/encoding/parameters_sync.rs rename to data-model/src/encoding/traits_sync.rs diff --git a/data-model/src/encoding/unsigned_int.rs b/data-model/src/encoding/unsigned_int.rs index e55ad1b..2e8ea1f 100644 --- a/data-model/src/encoding/unsigned_int.rs +++ b/data-model/src/encoding/unsigned_int.rs @@ -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(&self, consumer: &mut Consumer) -> Result<(), Consumer::Error> diff --git a/data-model/src/entry.rs b/data-model/src/entry.rs index fe6eed6..c94cbb2 100644 --- a/data-model/src/entry.rs +++ b/data-model/src/entry.rs @@ -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, }; @@ -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 Encodable for Entry diff --git a/data-model/src/path.rs b/data-model/src/path.rs index ddbdfe0..4707103 100644 --- a/data-model/src/path.rs +++ b/data-model/src/path.rs @@ -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 Encodable for Path { async fn encode(&self, consumer: &mut C) -> Result<(), C::Error> diff --git a/earthstar/src/cinn25519.rs b/earthstar/src/cinn25519.rs index 0acc49b..be3fa3a 100644 --- a/earthstar/src/cinn25519.rs +++ b/earthstar/src/cinn25519.rs @@ -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(pub Vec); diff --git a/earthstar/src/identity_id.rs b/earthstar/src/identity_id.rs index ccf05d3..48d5550 100644 --- a/earthstar/src/identity_id.rs +++ b/earthstar/src/identity_id.rs @@ -1,10 +1,7 @@ use arbitrary::Arbitrary; use ufotofu::local_nb::{BulkConsumer, BulkProducer}; use willow_data_model::{ - encoding::{ - error::DecodeError, - parameters::{Decodable, Encodable}, - }, + encoding::{Decodable, DecodeError, Encodable}, SubspaceId, }; diff --git a/earthstar/src/namespace_id.rs b/earthstar/src/namespace_id.rs index 66c6a39..b90c688 100644 --- a/earthstar/src/namespace_id.rs +++ b/earthstar/src/namespace_id.rs @@ -1,10 +1,7 @@ use arbitrary::Arbitrary; use ufotofu::local_nb::{BulkConsumer, BulkProducer}; use willow_data_model::{ - encoding::{ - error::DecodeError, - parameters::{Decodable, Encodable}, - }, + encoding::{Decodable, DecodeError, Encodable}, NamespaceId, }; diff --git a/fuzz/fuzz_targets/mc_is_authorised_write.rs b/fuzz/fuzz_targets/mc_is_authorised_write.rs index f4db213..88d0def 100644 --- a/fuzz/fuzz_targets/mc_is_authorised_write.rs +++ b/fuzz/fuzz_targets/mc_is_authorised_write.rs @@ -4,7 +4,7 @@ use libfuzzer_sys::fuzz_target; use meadowcap::{AccessMode, McAuthorisationToken}; use signature::Signer; use ufotofu::sync::consumer::IntoVec; -use willow_data_model::encoding::parameters_sync::Encodable; +use willow_data_model::encoding::sync::Encodable; use willow_data_model::Entry; use willow_data_model::IsAuthorisedWrite; use willow_data_model_fuzz::{ diff --git a/fuzz/fuzz_targets/u16be_encoding.rs b/fuzz/fuzz_targets/u16be_encoding.rs index 1413115..8cc2749 100644 --- a/fuzz/fuzz_targets/u16be_encoding.rs +++ b/fuzz/fuzz_targets/u16be_encoding.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::encoding::unsigned_int::U16BE; +use willow_data_model::encoding::U16BE; use willow_data_model_fuzz::encode::encoding_roundtrip; fuzz_target!(|data: (u16, TestConsumer)| { diff --git a/fuzz/fuzz_targets/u16be_encoding_random.rs b/fuzz/fuzz_targets/u16be_encoding_random.rs index e664001..ae551c7 100644 --- a/fuzz/fuzz_targets/u16be_encoding_random.rs +++ b/fuzz/fuzz_targets/u16be_encoding_random.rs @@ -1,7 +1,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::encoding::unsigned_int::U16BE; +use willow_data_model::encoding::U16BE; use willow_data_model_fuzz::encode::encoding_random; fuzz_target!(|data: &[u8]| { diff --git a/fuzz/fuzz_targets/u32be_encoding.rs b/fuzz/fuzz_targets/u32be_encoding.rs index 1cda4f7..6d63f34 100644 --- a/fuzz/fuzz_targets/u32be_encoding.rs +++ b/fuzz/fuzz_targets/u32be_encoding.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::encoding::unsigned_int::U32BE; +use willow_data_model::encoding::U32BE; use willow_data_model_fuzz::encode::encoding_roundtrip; fuzz_target!(|data: (u32, TestConsumer)| { diff --git a/fuzz/fuzz_targets/u32be_encoding_random.rs b/fuzz/fuzz_targets/u32be_encoding_random.rs index f0f4924..b676e18 100644 --- a/fuzz/fuzz_targets/u32be_encoding_random.rs +++ b/fuzz/fuzz_targets/u32be_encoding_random.rs @@ -1,7 +1,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::encoding::unsigned_int::U32BE; +use willow_data_model::encoding::U32BE; use willow_data_model_fuzz::encode::encoding_random; fuzz_target!(|data: &[u8]| { diff --git a/fuzz/fuzz_targets/u64be_encoding.rs b/fuzz/fuzz_targets/u64be_encoding.rs index 2a7781b..f9bcbfa 100644 --- a/fuzz/fuzz_targets/u64be_encoding.rs +++ b/fuzz/fuzz_targets/u64be_encoding.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::encoding::unsigned_int::U64BE; +use willow_data_model::encoding::U64BE; use willow_data_model_fuzz::encode::encoding_roundtrip; fuzz_target!(|data: (u64, TestConsumer)| { diff --git a/fuzz/fuzz_targets/u64be_encoding_random.rs b/fuzz/fuzz_targets/u64be_encoding_random.rs index 7e8acf4..b8e8883 100644 --- a/fuzz/fuzz_targets/u64be_encoding_random.rs +++ b/fuzz/fuzz_targets/u64be_encoding_random.rs @@ -1,7 +1,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::encoding::unsigned_int::U64BE; +use willow_data_model::encoding::U64BE; use willow_data_model_fuzz::encode::encoding_random; fuzz_target!(|data: &[u8]| { diff --git a/fuzz/fuzz_targets/u8be_encoding.rs b/fuzz/fuzz_targets/u8be_encoding.rs index d0b9f03..bc5a154 100644 --- a/fuzz/fuzz_targets/u8be_encoding.rs +++ b/fuzz/fuzz_targets/u8be_encoding.rs @@ -2,7 +2,7 @@ use libfuzzer_sys::fuzz_target; use ufotofu::local_nb::consumer::TestConsumer; -use willow_data_model::encoding::unsigned_int::U8BE; +use willow_data_model::encoding::U8BE; use willow_data_model_fuzz::encode::encoding_roundtrip; fuzz_target!(|data: (u8, TestConsumer)| { diff --git a/fuzz/fuzz_targets/u8be_encoding_random.rs b/fuzz/fuzz_targets/u8be_encoding_random.rs index 8082ac1..d03e64c 100644 --- a/fuzz/fuzz_targets/u8be_encoding_random.rs +++ b/fuzz/fuzz_targets/u8be_encoding_random.rs @@ -1,7 +1,7 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use willow_data_model::encoding::unsigned_int::U8BE; +use willow_data_model::encoding::U8BE; use willow_data_model_fuzz::encode::encoding_random; fuzz_target!(|data: &[u8]| { diff --git a/fuzz/src/encode.rs b/fuzz/src/encode.rs index 43d3072..a830a0e 100644 --- a/fuzz/src/encode.rs +++ b/fuzz/src/encode.rs @@ -8,8 +8,7 @@ use ufotofu::{ }; use willow_data_model::encoding::{ - error::DecodeError, - parameters::{Decodable, Encodable, RelativeDecodable, RelativeEncodable}, + DecodeError, {Decodable, Encodable, RelativeDecodable, RelativeEncodable}, }; pub async fn encoding_roundtrip(item: T, consumer: &mut TestConsumer) diff --git a/fuzz/src/placeholder_params.rs b/fuzz/src/placeholder_params.rs index 026a18a..6330c2c 100644 --- a/fuzz/src/placeholder_params.rs +++ b/fuzz/src/placeholder_params.rs @@ -2,9 +2,8 @@ use arbitrary::Arbitrary; use ufotofu::local_nb::{BulkConsumer, BulkProducer}; use ufotofu::sync::{BulkConsumer as BulkConsumerSync, BulkProducer as BulkProducerSync}; use willow_data_model::encoding::{ - error::DecodeError, - parameters::{Decodable, Encodable}, - parameters_sync::{Decodable as DecodableSync, Encodable as EncodableSync}, + sync::{Decodable as DecodableSync, Encodable as EncodableSync}, + Decodable, DecodeError, Encodable, }; use willow_data_model::PayloadDigest; diff --git a/fuzz/src/silly_sigs.rs b/fuzz/src/silly_sigs.rs index 630da5d..e2f6aee 100644 --- a/fuzz/src/silly_sigs.rs +++ b/fuzz/src/silly_sigs.rs @@ -83,12 +83,12 @@ pub mod encoding { #[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)] use ufotofu::local_nb::{BulkConsumer, BulkProducer}; - use willow_data_model::encoding::error::DecodeError; - #[syncify_replace(use willow_data_model::encoding::parameters_sync::{Encodable, Decodable};)] - use willow_data_model::encoding::parameters::{Decodable, Encodable}; + use willow_data_model::encoding::DecodeError; + #[syncify_replace(use willow_data_model::encoding::sync::{Encodable, Decodable};)] + use willow_data_model::encoding::{Decodable, Encodable}; - #[syncify_replace(use willow_data_model::encoding::bytes::encoding_sync::produce_byte;)] - use willow_data_model::encoding::bytes::encoding::produce_byte; + #[syncify_replace(use willow_data_model::encoding::sync::produce_byte;)] + use willow_data_model::encoding::produce_byte; impl Encodable for SillyPublicKey { async fn encode(&self, consumer: &mut Consumer) -> Result<(), Consumer::Error> diff --git a/meadowcap/src/communal_capability.rs b/meadowcap/src/communal_capability.rs index f244e8f..b257e01 100644 --- a/meadowcap/src/communal_capability.rs +++ b/meadowcap/src/communal_capability.rs @@ -1,7 +1,7 @@ use signature::{Signer, Verifier}; use ufotofu::{sync::consumer::IntoVec, sync::Consumer}; use willow_data_model::{ - encoding::parameters_sync::{Encodable, RelativeEncodable}, + encoding::sync::{Encodable, RelativeEncodable}, grouping::Area, NamespaceId, SubspaceId, }; diff --git a/meadowcap/src/mc_authorisation_token.rs b/meadowcap/src/mc_authorisation_token.rs index 73dade5..b3de612 100644 --- a/meadowcap/src/mc_authorisation_token.rs +++ b/meadowcap/src/mc_authorisation_token.rs @@ -1,8 +1,7 @@ use signature::Verifier; use ufotofu::sync::consumer::IntoVec; use willow_data_model::{ - encoding::parameters_sync::Encodable, Entry, IsAuthorisedWrite, NamespaceId, PayloadDigest, - SubspaceId, + encoding::sync::Encodable, Entry, IsAuthorisedWrite, NamespaceId, PayloadDigest, SubspaceId, }; use crate::{mc_capability::McCapability, AccessMode, IsCommunal}; diff --git a/meadowcap/src/mc_capability.rs b/meadowcap/src/mc_capability.rs index 8a1ef7f..b076ffb 100644 --- a/meadowcap/src/mc_capability.rs +++ b/meadowcap/src/mc_capability.rs @@ -4,8 +4,7 @@ use either::Either; use signature::{Error as SignatureError, Signer, Verifier}; use ufotofu::sync::consumer::IntoVec; use willow_data_model::{ - encoding::parameters_sync::Encodable, grouping::Area, Entry, NamespaceId, PayloadDigest, - SubspaceId, + encoding::sync::Encodable, grouping::Area, Entry, NamespaceId, PayloadDigest, SubspaceId, }; use crate::{ @@ -293,25 +292,20 @@ pub(super) mod encoding { #[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)] use ufotofu::local_nb::{BulkConsumer, BulkProducer}; - #[syncify_replace(use willow_data_model::encoding::parameters_sync::{Encodable, Decodable, RelativeDecodable, RelativeEncodable};)] - use willow_data_model::encoding::parameters::{ - Decodable, Encodable, RelativeDecodable, RelativeEncodable, - }; + #[syncify_replace(use willow_data_model::encoding::sync::{Encodable, Decodable, RelativeDecodable, RelativeEncodable};)] + use willow_data_model::encoding::{Decodable, Encodable, RelativeDecodable, RelativeEncodable}; use willow_data_model::encoding::{ - bytes::is_bitflagged, compact_width::CompactWidth, error::DecodeError, - parameters_sync::Encodable as EncodableSync, + is_bitflagged, sync::Encodable as EncodableSync, CompactWidth, DecodeError, }; - #[syncify_replace(use willow_data_model::encoding::bytes::encoding_sync::produce_byte;)] - use willow_data_model::encoding::bytes::encoding::produce_byte; + #[syncify_replace(use willow_data_model::encoding::sync::produce_byte;)] + use willow_data_model::encoding::produce_byte; #[syncify_replace( - use willow_data_model::encoding::compact_width::encoding_sync::{encode_compact_width_be, decode_compact_width_be}; + use willow_data_model::encoding::sync::{encode_compact_width_be, decode_compact_width_be}; )] - use willow_data_model::encoding::compact_width::encoding::{ - decode_compact_width_be, encode_compact_width_be, - }; + use willow_data_model::encoding::{decode_compact_width_be, encode_compact_width_be}; impl< const MCL: usize, diff --git a/meadowcap/src/mc_subspace_capability.rs b/meadowcap/src/mc_subspace_capability.rs index 91001aa..ffa07fa 100644 --- a/meadowcap/src/mc_subspace_capability.rs +++ b/meadowcap/src/mc_subspace_capability.rs @@ -1,6 +1,6 @@ use signature::{Error as SignatureError, Signer, Verifier}; use ufotofu::sync::{consumer::IntoVec, Consumer}; -use willow_data_model::encoding::parameters_sync::Encodable; +use willow_data_model::encoding::sync::Encodable; use willow_data_model::NamespaceId; use willow_data_model::SubspaceId; @@ -233,23 +233,20 @@ pub(super) mod encoding { #[syncify_replace(use ufotofu::sync::{BulkConsumer, BulkProducer};)] use ufotofu::local_nb::{BulkConsumer, BulkProducer}; - #[syncify_replace(use willow_data_model::encoding::parameters_sync::{Encodable, Decodable};)] - use willow_data_model::encoding::parameters::{Decodable, Encodable}; + #[syncify_replace(use willow_data_model::encoding::sync::{Encodable, Decodable};)] + use willow_data_model::encoding::{Decodable, Encodable}; use willow_data_model::encoding::{ - compact_width::CompactWidth, error::DecodeError, - parameters_sync::Encodable as EncodableSync, + sync::Encodable as EncodableSync, CompactWidth, DecodeError, }; - #[syncify_replace(use willow_data_model::encoding::bytes::encoding_sync::produce_byte;)] - use willow_data_model::encoding::bytes::encoding::produce_byte; + #[syncify_replace(use willow_data_model::encoding::sync::produce_byte;)] + use willow_data_model::encoding::produce_byte; #[syncify_replace( - use willow_data_model::encoding::compact_width::encoding_sync::{encode_compact_width_be, decode_compact_width_be}; + use willow_data_model::encoding::sync::{encode_compact_width_be, decode_compact_width_be}; )] - use willow_data_model::encoding::compact_width::encoding::{ - decode_compact_width_be, encode_compact_width_be, - }; + use willow_data_model::encoding::{decode_compact_width_be, encode_compact_width_be}; impl Encodable for McSubspaceCapability< diff --git a/meadowcap/src/owned_capability.rs b/meadowcap/src/owned_capability.rs index 6a6c01b..4c0d231 100644 --- a/meadowcap/src/owned_capability.rs +++ b/meadowcap/src/owned_capability.rs @@ -1,7 +1,7 @@ use signature::{Error as SignatureError, Signer, Verifier}; use ufotofu::{sync::consumer::IntoVec, sync::Consumer}; use willow_data_model::{ - encoding::parameters_sync::{Encodable, RelativeEncodable}, + encoding::sync::{Encodable, RelativeEncodable}, grouping::{Area, AreaSubspace}, NamespaceId, Path, SubspaceId, };