# Imports
ASN.1 IMPORTS are converted to Rust `use` statements. Three modes are
available, selected by CLI flag or `CodeGenConfig`.
## Default (no import prefix)
No `use` statements are emitted for imported types. Types are expected to be in
scope by other means (e.g., a hand-written `mod.rs`).
## `--crate-imports`
```sh
synta-codegen schema.asn1 --crate-imports -o src/generated.rs
```
Generates:
```rust
use crate::pkix::AlgorithmIdentifier;
use crate::pkix::Name;
```
Module name is the snake_case form of the ASN.1 module name from which the type
is imported.
## `--super-imports`
```sh
synta-codegen schema.asn1 --super-imports -o src/generated.rs
```
Generates:
```rust
use super::pkix::AlgorithmIdentifier;
use super::pkix::Name;
```
Useful when the generated file lives inside a subdirectory module and the parent
module re-exports the dependencies.
## `--module-prefix`
```sh
synta-codegen schema.asn1 --module-prefix my_crate -o src/generated.rs
```
Generates:
```rust
use my_crate::pkix::AlgorithmIdentifier;
use my_crate::pkix::Name;
```
The prefix is prepended verbatim followed by `::`.
## Multiple import sources
ASN.1 may import from several modules in one `IMPORTS` block:
```asn1
IMPORTS
Type1, Type2 FROM Module1
Type3 FROM Module2
Type4, Type5 FROM Module3;
```
Each source module produces one `use` statement. Multiple types from the same
module are grouped into a brace list:
```rust
use crate::module1::{Type1, Type2};
use crate::module2::Type3;
use crate::module3::{Type4, Type5};
```
## Library API
```rust
use synta_codegen::{CodeGenConfig, StringTypeMode};
// use crate::module_name::Type
let config = CodeGenConfig::with_crate_imports();
// use super::module_name::Type
let config = CodeGenConfig::with_super_imports();
// use my_lib::module_name::Type
let config = CodeGenConfig::with_custom_prefix("my_lib");
```
Override additional settings with struct-update syntax:
```rust
use synta_codegen::{CodeGenConfig, StringTypeMode};
let config = CodeGenConfig {
string_type_mode: StringTypeMode::Borrowed,
..CodeGenConfig::with_crate_imports()
};
```
## Circular import detection
```sh
synta-codegen base.asn1 user.asn1 --check-imports
```
Parses all input files and checks for circular module import cycles. If a cycle
is detected, the tool reports it and exits with a non-zero status. No code is
generated.