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: Add module wrapper to ASN.1 literal usage examples #7

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 49,10 @@ fn main() {
// set an output path for the generated rust code
.set_output_path(PathBuf::from("./asn/generated.rs"))
// you may also compile literal ASN1 snippets
.add_asn_literal("My-test-integer ::= INTEGER (1..128)")
.add_asn_literal(format!(
"TestModule DEFINITIONS AUTOMATIC TAGS::= BEGIN {} END",
"My-test-integer ::= INTEGER (1..128)"
))
.compile() {
Ok(warnings /* Vec<Box<dyn Error>> */) => { /* handle compilation warnings */ }
Err(error /* Box<dyn Error> */) => { /* handle unrecoverable compilation error */ }
Expand Down
25 changes: 20 additions & 5 deletions rasn-compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 38,10 @@
//! // set an output path for the generated rust code
//! .set_output_path(PathBuf::from("./asn/generated.rs"))
//! // you may also compile literal ASN1 snippets
//! .add_asn_literal("My-test-integer ::= INTEGER (1..128)")
//! .add_asn_literal(format!(
//! "TestModule DEFINITIONS AUTOMATIC TAGS::= BEGIN {} END",
//! "My-test-integer ::= INTEGER (1..128)"
//! ))
//! .compile() {
//! Ok(warnings /* Vec<Box<dyn Error>> */) => { /* handle compilation warnings */ }
//! Err(error /* Box<dyn Error> */) => { /* handle unrecoverable compilation error */ }
Expand Down Expand Up @@ -235,7 238,10 @@ impl<B: Backend> Compiler<B, CompilerMissingParams> {
/// * `literal` - literal ASN1 statement to include
/// ```rust
/// # use rasn_compiler::Compiler;
/// Compiler::new().add_asn_literal("My-test-integer ::= INTEGER (1..128)").compile_to_string();
/// Compiler::new().add_asn_literal(format!(
/// "TestModule DEFINITIONS AUTOMATIC TAGS::= BEGIN {} END",
/// "My-test-integer ::= INTEGER (1..128)"
/// )).compile_to_string();
/// ```
pub fn add_asn_literal(self, literal: impl Into<String>) -> Compiler<B, CompilerSourcesSet> {
Compiler {
Expand Down Expand Up @@ -298,7 304,10 @@ impl<B: Backend> Compiler<B, CompilerOutputSet> {
/// * `literal` - literal ASN1 statement to include
/// ```rust
/// # use rasn_compiler::Compiler;
/// Compiler::new().add_asn_literal("My-test-integer ::= INTEGER (1..128)").compile_to_string();
/// Compiler::new().add_asn_literal(format!(
/// "TestModule DEFINITIONS AUTOMATIC TAGS::= BEGIN {} END",
/// "My-test-integer ::= INTEGER (1..128)"
/// )).compile_to_string();
/// ```
pub fn add_asn_literal(self, literal: impl Into<String>) -> Compiler<B, CompilerReady> {
Compiler {
Expand Down Expand Up @@ -344,7 353,10 @@ impl<B: Backend> Compiler<B, CompilerSourcesSet> {
/// * `literal` - literal ASN1 statement to include
/// ```rust
/// # use rasn_compiler::Compiler;
/// Compiler::new().add_asn_literal("My-test-integer ::= INTEGER (1..128)").compile_to_string();
/// Compiler::new().add_asn_literal(format!(
/// "TestModule DEFINITIONS AUTOMATIC TAGS::= BEGIN {} END",
/// "My-test-integer ::= INTEGER (1..128)"
/// )).compile_to_string();
/// ```
pub fn add_asn_literal(self, literal: impl Into<String>) -> Compiler<B, CompilerSourcesSet> {
let mut sources: Vec<AsnSource> = self.state.sources;
Expand Down Expand Up @@ -470,7 482,10 @@ impl<B: Backend> Compiler<B, CompilerReady> {
/// * `literal` - literal ASN1 statement to include
/// ```rust
/// # use rasn_compiler::Compiler;
/// Compiler::new().add_asn_literal("My-test-integer ::= INTEGER (1..128)").compile_to_string();
/// Compiler::new().add_asn_literal(format!(
/// "TestModule DEFINITIONS AUTOMATIC TAGS::= BEGIN {} END",
/// "My-test-integer ::= INTEGER (1..128)"
/// )).compile_to_string();
/// ```
pub fn add_asn_literal(self, literal: impl Into<String>) -> Compiler<B, CompilerReady> {
let mut sources: Vec<AsnSource> = self.state.sources;
Expand Down