You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The serialization and deserialization process was completely revamped to replace the code generation that uses string concatenation and instead utilize (smaller) proc-macros and types for it.
10
+
The previous - now called legacy codegen - is still available, but deprecated and hidden behind the `legacy-uper-codegen` and `legacy-protobuf-codegen` feature.
11
+
It will be **removed in 0.3.0**.
12
+
13
+
Feel free to visit [the tests](tests) to learn about the new usage. You might want to start with the [showcase].
27
14
28
15
### Fixes
16
+
- lots of smaller and niche parsing errors
29
17
- Implement the canonical order for tags (ITU-T X.680 | ISO/IEC 8824-1, 8.6)
18
+
- Missing CI checks on non-default features
30
19
31
20
### Added
21
+
- support for ASN-extensible `CHOICE` and `ENUMERATED` types
22
+
-`Reader`, `Writer` traits to (de)serialize based on the visitor pattern, asn attribute annotation, see [showcase] and [proc_macro_attribute]. This will allow further ASN encodings to be implemented without further code generation (to be clear, this not on the roadmap for now, but PRs are welcome).
32
23
- Support for `INTEGER` constants
33
24
- Support for extensible `SEQUENCE`s
34
25
- Support for extensible `INTEGER`s
35
26
- Support for `BIT STRING`, as well as the `SIZE` constraint, constants, and the extensible flag
36
27
- Support for `IA5String`, as well as the `SIZE` constraint, and the extensible flag
37
28
- Support for `SIZE` constraints for `OCTET STRING`s
38
29
- Support for `SIZE` constraints for `UTF8String`s
39
-
- Support for `SIZE` constraints for `SEQUENCE OF`s
40
-
- ASN.1 Support Overview to README
41
-
42
-
### Changes
43
-
- Parse/Accept ObjectIdentifier in `FROM` directives and module definitions
44
-
- The whole module `crate::io::uper` is now **deprecated**
45
-
- Reimplemented all low level uPER functions - this time strictly according to specification and using names mentioned there, see ```crate::io::per```
46
-
- Better prepare for alternative encoding rules (especially aligned PER, although this is no specific goal)
47
-
- Help the compiler in figuring out where const evaluations are possible (see `const_*!` macros)
48
-
- Lots of `#[inline]` hinting
30
+
- Support for `SIZE` constraints for `SEQUENCE OF`s
31
+
- Support for `SET`s and `SET OF`s\*
32
+
- Support for extensible `SET`s
33
+
- Support for `SIZE` constraints for `SET OF`s
34
+
-`TagResolver` to properly resolve Tags of ASN.1 types
35
+
-`syn::common::Constraint` which has `const TAG: Tag` and implementation for all generated constraint types
36
+
- CI checks for specific feature combinations
49
37
50
38
51
-
# 0.2.0-alpha1 (May 13, 2020)
52
39
53
-
### Fixes
54
-
- lots of smaller and niche parsing errors
55
-
56
-
### Added
57
-
- support for ASN-extensible `CHOICE` and `ENUMERATED` types
58
-
-`Reader`, `Writer` traits to (de)serialize based on the visitor pattern, asn attribute annotation, see [showcase] and [proc_macro_attribute]. This will allow further ASN encodings to be implemented without further code generation (to be clear, this not on the roadmap for now, but PRs are welcome).
40
+
\* For `SET OF` only BASIC-PER encoding is supported currently, see [#20](https://github.com/kellerkindt/asn1rs/issues/20)
59
41
60
42
### Changes
61
-
- deprecated `UperSerializer` which generates a lot of complex code for (uper-)serialization. Instead general purpose and less complex code that is based on the visitor pattern will be generated. See [showcase] and commits linked to [#11]. This also allows to write ASN serializable structures without writing ASN itself (see [proc_macro_attribute]):
43
+
- Added ASN.1 Support Overview to README
44
+
- Deprecated `UperSerializer` which generates a lot of complex code for (uper-)serialization. Instead general purpose and less complex code that is based on the visitor pattern will be generated. See [showcase] and commits linked to [#11]. This also allows to write ASN serializable structures without writing ASN itself (see [proc_macro_attribute]):
62
45
63
46
```rust
64
47
#[asn(sequence)]
@@ -87,6 +70,15 @@ fn pizza_test_uper_1() {
87
70
}
88
71
89
72
```
73
+
- Parse/Accept ObjectIdentifier in `FROM` directives and module definitions
74
+
- The module `crate::io::uper` is now **deprecated**
75
+
- Reimplemented all low level uPER functions - this time strictly according to specification and using names mentioned there, see ```crate::io::per```
76
+
- Better prepare for alternative encoding rules (especially aligned PER, although this is no specific goal)
77
+
- Help the compiler in figuring out where const evaluations are possible (see `const_*!` macros)
78
+
- Lots of `#[inline]` hinting
79
+
- The ASN.1 `OPTIONAL` type is now represented as `optional` instead of `option` in `#[asn(..)]`
80
+
- The protobuf serializer is now optional and can be enabled with the `protobuf` feature flag
81
+
- Deprecated `Protobuf` trait which is replaced by `ProtobufReader` and `ProtobufWriter` that use the common `Readable` and `Writable` traits
The following example generates Rust, Protobuf and SQL files for all ```.asn1```-files in the ```asn/``` directory of the project.
99
+
The following example generates Rust, Protobuf and SQL files for all ```.asn1```-files in the ```asn/``` directory of a workspace.
96
100
While the generated Rust code is written to the ```src/``` directory, the Protobuf files are written to ```proto/``` and the SQL files are written to ```sql/ ```.
97
-
Additionally, in this example each generated Rust-Type also receives ```Serialize``` and ```Deserialize``` derive directives (```#[derive(Serialize, Deserialize)]```) for automatic [serde](https://crates.io/crates/serde) integration.
101
+
Additionally, in this example each generated Rust-Type also receives ```Serialize``` and ```Deserialize``` derive directives (```#[derive(Serialize, Deserialize)]```) for [serde](https://crates.io/crates/serde) integration.
98
102
99
103
Sample ```build.rs``` file:
100
104
@@ -124,8 +128,8 @@ pub fn main() {
124
128
.filter(|entry|entry.ends_with(".asn1"))
125
129
})
126
130
.for_each(|path| {
131
+
println!("cargo:rerun-if-changed={}", path);
127
132
ifletErr(e) =converter.load_file(&path) {
128
-
println!("cargo:rerun-if-changed={}", path);
129
133
panic!("Loading of .asn1 file failed {}: {:?}", path, e);
130
134
}
131
135
});
@@ -157,9 +161,9 @@ pub fn main() {
157
161
158
162
```
159
163
160
-
####Inlining ASN.1 with procedural macros
164
+
###Example: Inlining ASN.1 with procedural macros
161
165
162
-
Minimal example by inlining the ASN.1 definition. For more examples, see ```tests/```.
166
+
Minimal example by inlining the ASN.1 definition. For more examples see [tests/](tests).
163
167
```rust
164
168
useasn1rs::prelude::*;
165
169
@@ -191,7 +195,7 @@ fn test_write_read() {
191
195
#[test]
192
196
fntest_constraint_eq() {
193
197
// these types should normally not be accessed, but in this exampled they show
194
-
// the way the ASN.1 constraints are encoded in to the struct type constraints.
198
+
// the way the ASN.1 constraints are encoded with the Rust type system.
195
199
useasn1rs::syn::numbers::Constraint;
196
200
assert_eq!(
197
201
___asn1rs_RangedMaxField0Constraint::MIN,
@@ -205,7 +209,7 @@ fn test_constraint_eq() {
205
209
```
206
210
207
211
208
-
####Example ASN.1-Definition to Rust, Protobuf and SQL
212
+
### Example: ASN.1-Definition converted to Rust, Protobuf and SQL
209
213
210
214
Minimal example showcasing what is being generated from an ASN.1 definition:
211
215
@@ -231,25 +235,21 @@ pub struct Header {
231
235
#[asn(integer(0..1209600000))] pubtimestamp:u32,
232
236
}
233
237
234
-
//OPTIONAL: Insert and query functions for async PostgreSQL
238
+
//only with the feature "async-psql": Insert and query functions for async PostgreSQL
// OPTIONAL: Serialize and deserialize functions for protobuf
243
-
implProtobufEqforHeader { /*..*/ }
244
-
implProtobufforHeader { /*..*/ }
245
-
246
-
// OPTIONAL: Insert and query functions for non-async PostgreSQL
246
+
// only with the feature "psql": Insert and query functions for non-async PostgreSQL
247
247
implPsqlRepresentableforHeader { /*..*/ }
248
248
implPsqlInsertableforHeader { /*..*/ }
249
249
implPsqlQueryableforHeader { /*..*/ }
250
250
```
251
251
252
-
OPTIONAL: The generated protobuf file:
252
+
The generated protobuf file (optional):
253
253
254
254
```proto
255
255
syntax = 'proto3';
@@ -260,7 +260,7 @@ message Header {
260
260
}
261
261
```
262
262
263
-
OPTIONAL: The generated (p)sql file:
263
+
The generated SQL file (optional):
264
264
265
265
```sql
266
266
DROPTABLE IF EXISTS Header CASCADE;
@@ -271,11 +271,11 @@ CREATE TABLE Header (
271
271
);
272
272
```
273
273
274
-
#### Example usage of async postgres
274
+
#### Example: Usage of async postgres
275
275
NOTE: This requires the `async-psql` feature.
276
276
277
-
Using async postgres allows the message - or the batched messages - to take advantage of [`pipelining`] automatically.
278
-
This can provide a speedup (personal experience: at around 26%) compared to the synchronous/blocking postgres implementation.
277
+
Using async postgres allows the message - or the batched messages - to take advantage of [`pipelining`].
278
+
This can provide a significant speedup for deep message types (personal experience this is around 26%) compared to the synchronous/blocking postgres implementation.
279
279
280
280
```rust
281
281
useasn1rs::io::async_psql::*;
@@ -342,7 +342,7 @@ async fn main() {
342
342
}
343
343
```
344
344
345
-
#### Raw uPER usage
345
+
#### Example: Raw uPER usage
346
346
The module ```asn1rs::io``` exposes (de-)serializers and helpers for direct usage without ASN.1 definition:
0 commit comments