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

Integer as enum type and optimized constrained and variable-sized integer encoding #289

Merged
merged 24 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
26d37ac
Initial working version for optimized integer encoding
Nicceboy Aug 4, 2024
c9c3d90
Add int bench
Nicceboy Aug 4, 2024
3ec3ef2
OER: Reduce integer-related allocations
Nicceboy Aug 4, 2024
e22b81a
Add some docs, typo fixes
Nicceboy Aug 4, 2024
019ff68
Fix jer integer encoding
Nicceboy Aug 4, 2024
649be39
Fix integer encoding of unsigned as signed bytes, cleanup
Nicceboy Aug 5, 2024
2250c98
PER: reduce unwraps on integer encoding
Nicceboy Aug 5, 2024
956b382
Initial adjusted version
Nicceboy Aug 22, 2024
6e254e3
Fix jer integer encoding
Nicceboy Aug 22, 2024
11cf3a0
OER: remove unnecessary use of custom to_vec method on BitVec
Nicceboy Aug 22, 2024
1f11a98
Integer types cleanup
Nicceboy Aug 23, 2024
f72a7a0
Impl Encode for BigInt, clippy fixes, custom PartialEq
Nicceboy Sep 3, 2024
3af53e5
Bug fixes, clippy, associated UnsignedPair and SignedPair types
Nicceboy Sep 4, 2024
bf67724
Docs
Nicceboy Sep 4, 2024
eea2331
Unnecessary full type in Decode for ConstrainedInteger
Nicceboy Sep 4, 2024
1f770b5
Add extra integer tests
Nicceboy Sep 4, 2024
15aded2
All int bench tests
Nicceboy Sep 4, 2024
2998960
PER: explicit usize decoding for choice
Nicceboy Sep 4, 2024
f76fb80
Remove unnecessary parentheses
Nicceboy Sep 4, 2024
e8aa299
Inline some core functions of IntegerType trait
Nicceboy Sep 4, 2024
92d28a7
PER: parse integer small optimization
Nicceboy Sep 4, 2024
8f8eda6
Make constraint minimum copy explicit
Nicceboy Sep 4, 2024
73ab9f6
One clone less in constraints
Nicceboy Sep 4, 2024
0ff9f8b
More integer tests
Nicceboy Sep 4, 2024
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
92 changes: 51 additions & 41 deletions Cargo.lock

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

12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ name = "iai"
path = "benches/iai.rs"
harness = false

[[bench]]
name = "criterion_integer"
path = "benches/integer.rs"
harness = false
test = true

[dependencies]
nom = { version = "7.1.3", default-features = false, features = ["alloc"] }
num-bigint = { version = "0.4.3", default-features = false }
Expand All @@ -59,11 +65,11 @@ nom-bitvec = { package = "bitvec-nom2", version = "0.2.0" }
arrayvec = { version = "0.7.4", default-features = false }
either = { version = "1.9.0", default-features = false }
once_cell = { version = "1.18.0", default-features = false, features = [
"race",
"alloc",
"race",
"alloc",
] }
num-integer = { version = "0.1.45", default-features = false, features = [
"i128",
"i128",
] }
jzon = { version = "0.12.5", optional = true }

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ type TestTypeB = bool;
type TestTypeA = TestTypeB;
```
```rust
// or
// or
use rasn::prelude::*;

#[derive(AsnType, Decode, Encode)]
Expand Down Expand Up @@ -621,11 +621,11 @@ Test-type-a ::= CHOICE {
raisin OCTET STRING
}
Test-type-b ::= CHOICE {
juice INTEGER (0..3,...),
Test-type-b ::= CHOICE {
juice INTEGER (0..3,...),
wine OCTET STRING,
...,
grappa INTEGER
grappa INTEGER
}
```

Expand Down Expand Up @@ -663,8 +663,8 @@ enum TestTypeB {
<td>

```asn
Test-type-a ::= SEQUENCE {
juice INTEGER (0..3,...),
Test-type-a ::= SEQUENCE {
juice INTEGER (0..3,...),
wine OCTET STRING,
...,
grappa INTEGER OPTIONAL,
Expand Down Expand Up @@ -699,7 +699,7 @@ struct TestTypeA {
<td>

```asn
Test-type-a ::= SET {
Test-type-a ::= SET {
seed NULL,
grape BOOLEAN,
raisin INTEGER
Expand All @@ -711,7 +711,7 @@ Test-type-a ::= SET {

```rust
use rasn::prelude::*;
/// the SET declaration is basically identical to a SEQUENCE declaration,
/// the SET declaration is basically identical to a SEQUENCE declaration,
/// except for the `set` annotation
#[derive(AsnType, Decode, Encode)]
#[rasn(set, automatic_tags)]
Expand All @@ -730,7 +730,7 @@ struct TestTypeA {
<td>

```asn
Test-type-a ::= SEQUENCE {
Test-type-a ::= SEQUENCE {
notQuiteRustCase INTEGER
}
```
Expand All @@ -757,7 +757,7 @@ struct TestTypeA {
<td>

```asn
Test-type-a ::= SEQUENCE {
Test-type-a ::= SEQUENCE {
seed BOOLEAN DEFAULT TRUE,
grape INTEGER OPTIONAL,
raisin INTEGER DEFAULT 1
Expand All @@ -773,7 +773,7 @@ use rasn::prelude::*;
#[derive(AsnType, Decode, Encode)]
#[rasn(automatic_tags)]
struct TestTypeA {
#[rasn(default = "default_seed")]
#[rasn(default = "default_seed")]
seed: bool,
grape: Option<Integer>,
#[rasn(default = "default_raisin")]
Expand Down
Loading
Loading