-
Notifications
You must be signed in to change notification settings - Fork 127
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
[WIP] doc binary-sv2 #1231
base: main
Are you sure you want to change the base?
[WIP] doc binary-sv2 #1231
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1231 +/- ##
=======================================
Coverage 19.36% 19.36%
=======================================
Files 164 164
Lines 10811 10811
=======================================
Hits 2094 2094
Misses 8717 8717 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@Shourya742 I think you mentioned the wrong issues in the description |
Thanks for pointing it out... Now pointing to correct issues.. |
0744189
to
9185560
Compare
Bencher Report
Click to view all benchmark results
|
Bencher Report
Click to view all benchmark results
|
Bencher Report
Click to view all benchmark results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the first chunk of a review.
Some of the changes I suggested in decodable.rs
can be extrapolated to other files. Specifically we need to avoid language like "This method", "This implementation", etc. and just directly say what it is (the language does not really need to change beyond the removal of the qualifiers). Also, we need to make sure each line goes up to 100 characters.
Do we have examples to add?
@@ -10,13 +10,35 @@ use std::convert::TryFrom; | |||
#[cfg(not(feature = "no_std"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need top level comments here with a header title and an explainer of what the module is/does.
@@ -1,3 +1,64 @@ | |||
// This module provides an encoding framework for serializing various data types into bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need top level comments here with a header title and an explainer of what the module is/does.
/// Trait that defines how a type can be decoded from raw byte data. | ||
/// | ||
/// This trait describes the process of decoding a data structure from a sequence of bytes. | ||
/// Implementations use a combination of methods to extract the structure of the data, decode its | ||
/// fields, and then construct the type from those decoded fields. It is designed to handle both | ||
/// simple types and nested or complex data structures. | ||
/// | ||
/// - `get_structure`: Describes the layout of the type's fields, allowing the decoder to break down the raw data. | ||
/// - `from_decoded_fields`: Reconstructs the type from individual decoded fields. | ||
/// - `from_bytes`: High-level method that manages the decoding process from raw bytes. | ||
/// - `from_reader`: Reads and decodes data from a stream, useful when working with I/O sources like files or network sockets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to re-describe each method.
/// Trait that defines how a type can be decoded from raw byte data. | |
/// | |
/// This trait describes the process of decoding a data structure from a sequence of bytes. | |
/// Implementations use a combination of methods to extract the structure of the data, decode its | |
/// fields, and then construct the type from those decoded fields. It is designed to handle both | |
/// simple types and nested or complex data structures. | |
/// | |
/// - `get_structure`: Describes the layout of the type's fields, allowing the decoder to break down the raw data. | |
/// - `from_decoded_fields`: Reconstructs the type from individual decoded fields. | |
/// - `from_bytes`: High-level method that manages the decoding process from raw bytes. | |
/// - `from_reader`: Reads and decodes data from a stream, useful when working with I/O sources like files or network sockets. | |
/// Custom deserialization of types from binary data. | |
/// | |
/// Defines the process of reconstructing a type from a sequence of bytes. It handles both simple | |
/// and nested or complex data structures. |
fn get_structure(data: &[u8]) -> Result<Vec<FieldMarker>, Error>; | ||
|
||
/// Constructs the type from decoded fields. | ||
/// | ||
/// After the data has been split into fields, this method combines those fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extend the comment to 100 character line length
/// Returns the structure of the type. | ||
/// | ||
/// This method defines the layout of the data fields within the type. The structure | ||
/// returned is used to split raw data into individual fields that can be decoded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Returns the structure of the type. | |
/// | |
/// This method defines the layout of the data fields within the type. The structure | |
/// returned is used to split raw data into individual fields that can be decoded. | |
/// Defines the expected structure of a type in terms of individual fields, based on binary | |
/// data. | |
/// | |
/// This function returns a vector of `FieldMarker`s, each representing a component of the | |
/// structure. Useful for guiding the decoding process. |
Primitive(DecodablePrimitive<'a>), | ||
/// Represents vector of DecodableField |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Represents vector of DecodableField | |
/// Structured field, allowing for nested data structures. |
// | ||
// This implementation defines how to estimate the size of data represented by a `PrimitiveMarker`. | ||
// This is useful for efficient decoding, allowing the decoder to correctly split raw data into | ||
// fields of the right size. | ||
impl SizeHint for PrimitiveMarker { | ||
// PrimitiveMarker need introspection to return a size hint. This method is not implementeable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// PrimitiveMarker need introspection to return a size hint. This method is not implementeable | |
// PrimitiveMarker needs introspection to return a size hint. This method is not implementable. |
Struct(Vec<DecodableField<'a>>), | ||
} | ||
|
||
// Provides size hinting for each primitive marker. | ||
// | ||
// This implementation defines how to estimate the size of data represented by a `PrimitiveMarker`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rm "This implementation"
@@ -135,6 +192,10 @@ impl SizeHint for PrimitiveMarker { | |||
} | |||
} | |||
|
|||
// Provides size hinting for each field marker, including nested structures. | |||
// | |||
// This method defines how to estimate the size of a field, whether it's a primitive or a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rm "This method"
// Implements the decoding process for a `PrimitiveMarker`. | ||
// Given a slice of data and an offset, this method parses the corresponding data and returns | ||
// a `DecodablePrimitive`. This is the core mechanism for decoding primitive types like integers, | ||
// booleans, and fixed-length byte arrays from raw byte data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// booleans, and fixed-length byte arrays from raw byte data. | |
// Booleans, and fixed-length byte arrays from raw byte data. |
Closes: #1008 , #1009 , #1010