Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding relations API #51

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ the repo's issues, milestones, and projects.
protocol.
- [meadowcap-js](https://github.com/earthstar-project/meadowcap-js) - TypeScript
implementation of Meadowcap

## Fuzz tests

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.

```
cd fuzz
cargo fuzz run <test_name_here>
```

There is also a command for running all the fuzz tests sequentially:

```
cd fuzz
./run_all.sh -- -max_total_time=<number_of_seconds>
```

---

Expand Down
16 changes: 9 additions & 7 deletions data-model/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,18 @@ mod encoding {
S: SubspaceId + Decodable,
PD: PayloadDigest + Decodable,
{
async fn decode<Prod>(producer: &mut Prod) -> Result<Self, DecodeError<Prod::Error>>
async fn decode_canonical<Prod>(
producer: &mut Prod,
) -> Result<Self, DecodeError<Prod::Error>>
where
Prod: BulkProducer<Item = u8>,
{
let namespace_id = N::decode(producer).await?;
let subspace_id = S::decode(producer).await?;
let path = Path::<MCL, MCC, MPL>::decode(producer).await?;
let timestamp = U64BE::decode(producer).await?.into();
let payload_length = U64BE::decode(producer).await?.into();
let payload_digest = PD::decode(producer).await?;
let namespace_id = N::decode_canonical(producer).await?;
let subspace_id = S::decode_canonical(producer).await?;
let path = Path::<MCL, MCC, MPL>::decode_canonical(producer).await?;
let timestamp = U64BE::decode_canonical(producer).await?.into();
let payload_length = U64BE::decode_canonical(producer).await?.into();
let payload_digest = PD::decode_canonical(producer).await?;

Ok(Entry {
namespace_id,
Expand Down
11 changes: 8 additions & 3 deletions data-model/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,8 @@ mod encoding {
use ufotofu::local_nb::{BulkConsumer, BulkProducer};

use willow_encoding::DecodeError;
#[syncify_replace(use willow_encoding::sync::{Decodable, Encodable};)]
use willow_encoding::{Decodable, Encodable};
#[syncify_replace(use willow_encoding::sync::{Decodable, Encodable, RelationDecodable};)]
use willow_encoding::{Decodable, Encodable, RelationDecodable};

#[syncify_replace(use willow_encoding::sync::{decode_max_power, encode_max_power};)]
use willow_encoding::{decode_max_power, encode_max_power};
Expand All @@ -818,7 +818,7 @@ mod encoding {
}

impl<const MCL: usize, const MCC: usize, const MPL: usize> Decodable for Path<MCL, MCC, MPL> {
async fn decode<P>(producer: &mut P) -> Result<Self, DecodeError<P::Error>>
async fn decode_canonical<P>(producer: &mut P) -> Result<Self, DecodeError<P::Error>>
where
P: BulkProducer<Item = u8>,
{
Expand Down Expand Up @@ -855,6 +855,11 @@ mod encoding {
Ok(unsafe { buf.to_path(component_count) })
}
}

impl<const MCL: usize, const MCC: usize, const MPL: usize> RelationDecodable
for Path<MCL, MCC, MPL>
{
}
}

#[cfg(feature = "dev")]
Expand Down
Loading
Loading