Skip to content

Commit b819f8e

Browse files
committed
Documentation and Cargot.toml updates for publishing
1 parent f4b2dc6 commit b819f8e

File tree

27 files changed

+90
-27
lines changed

27 files changed

+90
-27
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Hampi - ASN.1 compiler in Rust
22

3-
The Goal of this project is to implement an ASN.1 Compiler in Rust which can generate Rust bindings for different ASN.1 specifications, which can be used in those protocol implementations in Rust.
3+
The Goal of this project is to implement an ASN.1 Compiler in Rust which can generate Rust bindings for different ASN.1 specifications, which can be used in various protocol implementations in Rust.
4+
5+
While it is certainly desirable to have a fully compliant ASN.1 Compiler, initial focus of the project is to be able to generate code that can be used in other software. First goal is to work with 3GPP specifications for protocols like Radio Network Access Protocl (RANAP), S1 Application protocl (S1AP) and NG Application Protocol (NGAP). Consequently current implementation also focuses on codecs used by these specifications viz. Aligned Packed Encoding Rules (APER).
6+
7+
The use cases targeted by this implementation are similar to the use cases targeted by `asn1c` compiler, which generates `C` bindings from the ASN.1 Specifications.
48

59
This project is divided into three crates -
610

7-
1. asn1-compiler: This crate provides the actual ASN.1 Compiler.
8-
2. asn-codecs: Support for different encodings supported by individual ASN.1 specifications is provided in this crate. Currently only APER Codec is supported. Each Codec is supported as a `trait` implementing `encode` and `decode` functions.
11+
1. asn1-compiler: This crate provides the actual ASN.1 Compiler. Typically a utility will be provided, that will generate Rust structures starting with ASN.1 Specifications. Basic working features required to work with the 3GPP specifications is provided by the compiler, this includes Parameterized Types, Information Object Classes and Type Constraints.
12+
2. asn-codecs: Support for different encodings supported by individual ASN.1 specifications is provided in this crate. Currently only APER Codec is supported. Each Codec is supported as a `trait` implementing `encode` and `decode` functions. Support for different 'encoding rules' will be implemented in this trait and then the derive macros will utilize this code to actually generate the encoding support for Rust Structures generated by the compiler above.
913
3. asn-codecs-derive: This crate provides the `derive` macros for the codecs in `asn-codecs`. The code generated using `asn-compiler` can be directed to `derive` appropriate codecs by passing the flags during compilation.
1014

1115
## Status
@@ -14,10 +18,11 @@ Currently specifications from the `specs/` directory can be compiled into respec
1418

1519
## Getting Started
1620

21+
The simplest way to try out this in action is - `cargo run --release specs/ngap/NGAP-* > ngap.rs` and then take a look at generated `ngap` module. (Better CLI support is coming soon.)
22+
1723
### Running Test Cases
1824

1925
1. Test cases can be run through `cargo test`.
2026
2. Right now `examples/` directory contains simple `decode` test cases for modules generated using the `asn-compiler`. This support will be improved to include the generated modules using mechanisms like `build.rs`.
2127

2228

23-

asn-compiler/Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
[package]
2-
name = "hampi"
3-
version = "0.0.1"
2+
name = "asn1-compiler"
3+
version = "0.1.0"
44
authors = ["Abhijit Gadgil <[email protected]>"]
55
edition = "2018"
66
description = "ASN.1 Compiler in Rust."
7-
repository = "https://github.com/gabhijit/intermodal.git"
8-
license = "MIT or Apache-2.0"
7+
keywords = ["asn1", "per"]
8+
repository = "https://github.com/gabhijit/hampi.git"
9+
license-file = "LICENSE"
910
readme = "README.md"
11+
include = ["src/**/*.rs", "README.md", "Cargo.toml", "LICENSE", "LICENSE-MIT", "LICENSE-Apache2"]
1012

11-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
13+
[badges]
14+
maintenance = { status = "actively-developed" }
1215

1316
[dependencies]
1417
lazy_static = { version = "1.4.0" }

asn-compiler/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE

asn-compiler/LICENSE-Apache2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE-Apache2

asn-compiler/LICENSE-MIT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE-MIT

asn-compiler/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md

asn-compiler/src/bin/hampi-asn1c.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::fs::File;
44
use std::io;
55

6-
use hampi::Asn1Compiler;
6+
use asn1_compiler::Asn1Compiler;
77

88
fn main() -> io::Result<()> {
99
let args: Vec<String> = std::env::args().collect();
@@ -13,9 +13,9 @@ fn main() -> io::Result<()> {
1313
for arg in &args[1..] {
1414
eprintln!("File: {}", arg);
1515
let file = File::open(arg)?;
16-
let mut tokens = hampi::tokenizer::tokenize(file)?;
16+
let mut tokens = asn1_compiler::tokenizer::tokenize(file)?;
1717
eprintln!("tokens: {}", tokens.len());
18-
let mut modules = hampi::parser::parse(&mut tokens)?;
18+
let mut modules = asn1_compiler::parser::parse(&mut tokens)?;
1919

2020
loop {
2121
let module = modules.pop();

asn-compiler/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub enum Error {
3131
/// Error related to resolving constraints for a type.
3232
ConstraintError(String),
3333

34-
/// Error related to resolving constraints for a type.
34+
/// Error related to code generation from resolved types.
3535
CodeGenerationError(String),
3636
}
3737

asn-compiler/src/generator/int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Code Generation module
22
3-
use heck::{CamelCase, ShoutySnakeCase, SnakeCase};
3+
use heck::{ShoutySnakeCase, SnakeCase};
44
use proc_macro2::{Ident, Literal, Span, TokenStream};
55

66
use quote::quote;

asn-compiler/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
//!
44
//! Goal of the project is to develop a compiler for ASN.1 specifications primarily for
55
//! applicatoins in working with 3GPP standards. The idea is to be able to generate Rust (and
6-
//! possibly other language(s)) bindings from ASN.1 Specifications.
6+
//! possibly other language(s)) bindings from ASN.1 Specifications. Initial support is targetted
7+
//! for generating Rust bindings.
78
9+
//! Error type for different types of Compilation Errors.
810
#[macro_use]
911
pub mod error;
1012

1113
/// ASN.1 Tokenizer and Related Types
1214
#[macro_use]
1315
pub mod tokenizer;
1416

15-
/// ASN1. Parser and Related Types
17+
/// ASN.1 Parser and Related Types
1618
pub mod parser;
1719

20+
/// ASN.1 Compiler Wrapper implmentation.
1821
mod compiler;
1922
pub use compiler::Asn1Compiler;
2023

24+
/// Types and Constraints resolution from the parsed types.
2125
pub mod resolver;
2226

27+
/// Code Generation from the resolved types.
2328
pub mod generator;

0 commit comments

Comments
 (0)