Skip to content

Commit 5b0a780

Browse files
authored
Merge pull request #51 from earthstar-project/encoding-relations
Encoding relations API
2 parents 569c3fe + 7ea01ff commit 5b0a780

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1478
-551
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ the repo's issues, milestones, and projects.
3535
protocol.
3636
- [meadowcap-js](https://github.com/earthstar-project/meadowcap-js) - TypeScript
3737
implementation of Meadowcap
38+
39+
## Fuzz tests
40+
41+
This repository has many fuzz tests. To use `cargo fuzz` commands, you must first make `fuzz` the working directory so that the nightly compiler (on which cargo-fuzz relies) is used for compiling the tests.
42+
43+
```
44+
cd fuzz
45+
cargo fuzz run <test_name_here>
46+
```
47+
48+
There is also a command for running all the fuzz tests sequentially:
49+
50+
```
51+
cd fuzz
52+
./run_all.sh -- -max_total_time=<number_of_seconds>
53+
```
3854

3955
---
4056

data-model/src/entry.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,18 @@ mod encoding {
196196
S: SubspaceId + Decodable,
197197
PD: PayloadDigest + Decodable,
198198
{
199-
async fn decode<Prod>(producer: &mut Prod) -> Result<Self, DecodeError<Prod::Error>>
199+
async fn decode_canonical<Prod>(
200+
producer: &mut Prod,
201+
) -> Result<Self, DecodeError<Prod::Error>>
200202
where
201203
Prod: BulkProducer<Item = u8>,
202204
{
203-
let namespace_id = N::decode(producer).await?;
204-
let subspace_id = S::decode(producer).await?;
205-
let path = Path::<MCL, MCC, MPL>::decode(producer).await?;
206-
let timestamp = U64BE::decode(producer).await?.into();
207-
let payload_length = U64BE::decode(producer).await?.into();
208-
let payload_digest = PD::decode(producer).await?;
205+
let namespace_id = N::decode_canonical(producer).await?;
206+
let subspace_id = S::decode_canonical(producer).await?;
207+
let path = Path::<MCL, MCC, MPL>::decode_canonical(producer).await?;
208+
let timestamp = U64BE::decode_canonical(producer).await?.into();
209+
let payload_length = U64BE::decode_canonical(producer).await?.into();
210+
let payload_digest = PD::decode_canonical(producer).await?;
209211

210212
Ok(Entry {
211213
namespace_id,

data-model/src/path.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,8 @@ mod encoding {
791791
use ufotofu::local_nb::{BulkConsumer, BulkProducer};
792792

793793
use willow_encoding::DecodeError;
794-
#[syncify_replace(use willow_encoding::sync::{Decodable, Encodable};)]
795-
use willow_encoding::{Decodable, Encodable};
794+
#[syncify_replace(use willow_encoding::sync::{Decodable, Encodable, RelationDecodable};)]
795+
use willow_encoding::{Decodable, Encodable, RelationDecodable};
796796

797797
#[syncify_replace(use willow_encoding::sync::{decode_max_power, encode_max_power};)]
798798
use willow_encoding::{decode_max_power, encode_max_power};
@@ -818,7 +818,7 @@ mod encoding {
818818
}
819819

820820
impl<const MCL: usize, const MCC: usize, const MPL: usize> Decodable for Path<MCL, MCC, MPL> {
821-
async fn decode<P>(producer: &mut P) -> Result<Self, DecodeError<P::Error>>
821+
async fn decode_canonical<P>(producer: &mut P) -> Result<Self, DecodeError<P::Error>>
822822
where
823823
P: BulkProducer<Item = u8>,
824824
{
@@ -855,6 +855,11 @@ mod encoding {
855855
Ok(unsafe { buf.to_path(component_count) })
856856
}
857857
}
858+
859+
impl<const MCL: usize, const MCC: usize, const MPL: usize> RelationDecodable
860+
for Path<MCL, MCC, MPL>
861+
{
862+
}
858863
}
859864

860865
#[cfg(feature = "dev")]

0 commit comments

Comments
 (0)