3 releases (breaking)

0.2.0 Aug 23, 2024
0.1.0 Jul 8, 2024
0.0.0-release Jul 8, 2024

#976 in Magic Beans

Download history 238/week @ 2024-07-06 17/week @ 2024-07-13 126/week @ 2024-08-17 29/week @ 2024-08-24

155 downloads per month
Used in 2 crates

Apache-2.0

10KB
118 lines

Essential Read

Crates.io Documentation license Build Status

This is a Rust library that contains utilities for reading and deserializing contracts and solutions. Functions skip subdirectories, non-JSON files and files that have non-valid UTF-8 names.

Return types are all wrapped in anyhow::Result, omitted in the rest of the README for simplicity.

Read Contract

Reads and deserializes predicates from a file.

Argument:

  • File as PathBuf.

Returns:

  • Vec<Predicate>, that is, a contract.

Read Contracts

Reads and deserializes contracts in a directory.

Argument:

  • Directory as PathBuf.

Returns:

  • Vec<Vec<Predicate>>, where the inner vector is a single contract.

Read Solution

Reads and deserializes a solution from a file.

Argument:

  • File as PathBuf.

Returns:

  • Solution.

Read Solutions

Reads and deserializes solutions in a directory.

Argument:

  • Directory as PathBuf.

Returns:

  • Vec<Solution>.

Read Bytes

Reads the contents of a file as bytes. This function can be used in cases where deserialization is not necessary.

Argument:

  • File as PathBuf.

Returns:

  • Vec<u8>.

Read Bytes (Directory)

Reads the contents of files in a directory as a vector of bytes. This function can be used in cases where deserialization is not necessary.

Argument:

  • Directory as PathBuf.

Returns:

  • Vec<Vec<u8>>, where each inner vector is the contents of a file.

Deserialize Contract

Deserializes a contract from bytes.

Argument:

  • Vec<u8>

Returns:

  • Vec<Predicate>, that is, a contract.

Deserialize Solution

Deserializes a solution from bytes.

Argument:

  • Vec<u8>

Returns:

  • Solution

Dependencies

~3–10MB
~96K SLoC