1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//! # `RustyASN` - ASN.1 Encoding for FIX Protocol
//!
//! This crate provides Abstract Syntax Notation One (ASN.1) encoding support for the FIX protocol.
//! It supports multiple encoding rules:
//!
//! - **BER** (Basic Encoding Rules) - Self-describing, flexible
//! - **DER** (Distinguished Encoding Rules) - Canonical subset of BER
//! - **OER** (Octet Encoding Rules) - Byte-aligned, efficient
//!
//! ## Features
//!
//! - Zero-copy decoding where possible
//! - Streaming support for continuous message processing
//! - Type-safe ASN.1 schema compilation
//! - Integration with `RustyFix` field types
//! - High-performance implementation optimized for low-latency trading
//!
//! ## ASN.1 Schema Compilation
//!
//! This crate uses a **custom ASN.1 parser implementation** in its build script rather than
//! the standard [`rasn-compiler`](https://crates.io/crates/rasn-compiler) crate. This
//! architectural decision was made due to version compatibility issues:
//!
//! ### Why Custom Parser?
//!
//! - **Version Incompatibility**: The rasn-compiler crate has compatibility issues with
//! rasn 0.18.x, which is used throughout the `RustyFix` project. Using rasn-compiler
//! would require either downgrading rasn or dealing with breaking API changes.
//!
//! - **FIX-Specific Optimizations**: The custom parser is tailored for FIX protocol
//! message structures and generates code that integrates seamlessly with `RustyFix`'s
//! type system and performance requirements.
//!
//! - **Build Stability**: The custom implementation is immune to breaking changes in
//! rasn-compiler updates, ensuring consistent builds across environments.
//!
//! - **Reduced Dependencies**: Eliminates rasn-compiler and its transitive dependencies,
//! reducing build complexity and potential security surface.
//!
//! ### Supported ASN.1 Features
//!
//! The custom parser supports the ASN.1 constructs commonly used in FIX protocol extensions:
//!
//! - SEQUENCE types with optional fields and explicit tags
//! - ENUMERATED types with explicit discriminant values
//! - CHOICE types with context-specific tags
//! - INTEGER types with constraint annotations
//! - String types (`UTF8String`, `PrintableString`, `VisibleString`, etc.)
//!
//! ### Migration Path
//!
//! Future migration to rasn-compiler will be considered when:
//! - rasn-compiler achieves stable compatibility with rasn 0.18.x+
//! - The `RustyFix` project upgrades to a newer rasn version
//! - The maintenance burden of the custom parser becomes significant
//!
//! For complex ASN.1 schemas requiring advanced features not implemented in the custom
//! parser, the build script provides fallback mechanisms and clear error messages.
//!
//! ## Usage
//!
//! ```rust,no_run
//! use rustyasn::{Config, Encoder, Decoder, EncodingRule};
//! use rustyfix::Dictionary;
//! use std::sync::Arc;
//!
//! fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Configure encoding
//! let config = Config::new(EncodingRule::OER);
//! let dictionary = Arc::new(Dictionary::fix44()?);
//!
//! // Create encoder and decoder
//! let encoder = Encoder::new(config.clone(), dictionary.clone());
//! let decoder = Decoder::new(config, dictionary);
//!
//! // Start encoding a message
//! let mut handle = encoder.start_message(
//! "D", // MsgType: NewOrderSingle
//! "SENDER", // SenderCompID
//! "TARGET", // TargetCompID
//! 1, // MsgSeqNum
//! );
//!
//! // Add fields and encode
//! handle.add_string(11, "ORDER001"); // ClOrdID
//! let encoded = handle.encode()?;
//!
//! // Decode the message
//! let message = decoder.decode(&encoded)?;
//! println!("Decoded message type: {}", message.msg_type());
//!
//! Ok(())
//! }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
// Re-export rasn types that users might need
pub use ;
/// Version information for the ASN.1 encoding implementation
pub const VERSION: &str = env!;
// Const generic buffer sizes for optimal performance
/// Default buffer size for field serialization (64 bytes)
pub const FIELD_BUFFER_SIZE: usize = 64;
/// Size for small field collections (8 fields)
pub const SMALL_FIELD_COLLECTION_SIZE: usize = 8;
/// Size for medium field collections (16 fields)
pub const MEDIUM_FIELD_COLLECTION_SIZE: usize = 16;
/// Maximum number of standard header fields
pub const MAX_HEADER_FIELDS: usize = 8;