hotfix_encoding/
config.rs

1const SOH: u8 = 0x1;
2const DEFAULT_MAX_MESSAGE_SIZE: usize = 0xffff;
3
4/// Configuration options for [`Encoder`](super::Encoder) and
5/// [`Decoder`](super::Decoder).
6#[derive(Debug, Copy, Clone)]
7#[non_exhaustive]
8pub struct Config {
9    /// The delimiter character, which terminates every tag-value pair including
10    /// the last one. This setting is relevant for both encoding and decoding
11    /// operations.
12    ///
13    /// ASCII 0x1 (SOH) is the default separator character.
14    pub separator: u8,
15    /// The maximum allowed size for any single FIX message. No restrictions are
16    /// imposed when it is [`None`].
17    pub max_message_size: Option<usize>,
18    /// Determines whether or not `CheckSum(10)` should be verified.
19    ///
20    /// This setting has no effect when encoding FIX messages.
21    pub verify_checksum: bool,
22    /// Determines whether or not the decoder needs to have access to
23    /// associative FIX fields. If turned off, only linear access is possible.
24    pub should_decode_associative: bool,
25}
26
27impl Default for Config {
28    fn default() -> Self {
29        Self {
30            separator: SOH,
31            max_message_size: Some(DEFAULT_MAX_MESSAGE_SIZE),
32            verify_checksum: true,
33            should_decode_associative: true,
34        }
35    }
36}
37
38/// Allows to get mutable and immutable references to configuration options.
39pub trait GetConfig {
40    /// The configuration options type.
41    type Config;
42
43    /// Returns an immutable reference to the configuration options used by
44    /// `self`.
45    fn config(&self) -> &Self::Config;
46
47    /// Returns a mutable reference to the configuration options used by
48    /// `self`.
49    fn config_mut(&mut self) -> &mut Self::Config;
50}