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

docs: document deserialization modules and update lib module's doc #1334

Merged
merged 11 commits into from
Jul 18, 2023
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#### Upcoming Changes

* docs: improve crate documentation [#1334](https://github.com/lambdaclass/cairo-vm/pull/1334)

* feat: add `arbitrary` feature to enable arbitrary derive in `Program` and `CairoRunConfig`

* feat(fuzzing): add `arbitrary` feature to enable arbitrary derive in `Program` and `CairoRunConfig` [#1306](https://github.com/lambdaclass/cairo-vm/pull/1306) [#1330](https://github.com/lambdaclass/cairo-vm/pull/1330)
Expand Down
11 changes: 8 additions & 3 deletions vm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
//! An implementation of the Cairo virtual machine
//! # An implementation of the Cairo virtual machine
//!
//! # Feature Flags
//! ## Feature Flags
//! - `std`: Enables usage of the [`std`] standard library. Enabled by default.
//! - `skip_next_instruction_hint`: Enable the `skip_next_instruction()` hint. Not enabled by default.
//! - `hooks`: Enable [Hooks](vm::hooks) support for the [VirtualMachine](vm::vm_core::VirtualMachine). Not enabled by default.
//! - `hooks`: Enable [`Hooks`](vm::hooks) support for the [VirtualMachine](vm::vm_core::VirtualMachine). Not enabled by default.
//! - `test_utils`: Enables test utils (`hooks` and `skip_next_instruction` features). Not enabled by default.
//! - `with_mimalloc`: Use [MiMalloc](https://crates.io/crates/mimalloc) as the program global allocator.
//! - `cairo-1-hints`: Enable hints that were introduced in Cairo 1. Not enabled by default.
//! - `arbitrary`: Enables implementations of [`arbitrary::Arbitrary`] for some structs. Not enabled by default.
//! - `lambdaworks-felt`: Enables usage of the [**lambdaworks**](https://github.com/lambdaclass/lambdaworks) backend for [`felt::Felt252`]. Not enabled by default.

#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(warnings)]
Expand Down
8 changes: 8 additions & 0 deletions vm/src/serde/deserialize_program.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//! # Program deserialization
//!
//! This module contains the logic for [`Program`] deserialization.
//! Users shouldn't need to use it directly (except for [`BuiltinName`]).
//!
//! To generate a [`Program`] from a JSON string, see [`Program::from_bytes()`].
//! To do the same from a JSON file, see [`Program::from_file()`].

use crate::stdlib::{collections::HashMap, fmt, prelude::*, sync::Arc};

use crate::vm::runners::builtin_runner::SEGMENT_ARENA_BUILTIN_NAME;
Expand Down
15 changes: 10 additions & 5 deletions vm/src/serde/deserialize_utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//! # Deserialization utils
//!
//! This module contains some helper functions used in [`Program`](crate::types::program::Program) deserialization.
//! Namely, [`maybe_add_padding`] and [`take_until_unbalanced`].
MegaRedHand marked this conversation as resolved.
Show resolved Hide resolved
//!
//! See [the docs](/docs/references_parsing/README.md) for context and grammar explanation.

use crate::stdlib::{fmt, num::ParseIntError, prelude::*, str::FromStr};

use crate::{
Expand Down Expand Up @@ -55,11 +62,9 @@ pub fn maybe_add_padding(mut hex: String) -> String {
hex
}

/*
NOM PARSERS
See the docs for context and grammar explanation:
cleopatra_cairo/docs/references_parsing/README.md
*/
// -----------------------
// NOM PARSERS
// -----------------------

// Checks if the input has outer brackets. This is used to set
// the `dereference` field of ValueAddress.
Expand Down
Loading