pub struct HexCodecConfig { /* private fields */ }Expand description
Configuration shared by crate::HexCodec encoding and decoding
operations.
The configuration is intentionally separate from the codec value so the same formatting and decoding policy can be reused by multiple codecs.
§Examples
use qubit_codec_misc::HexCodec;
use qubit_codec_misc::HexCodecConfig;
let config = HexCodecConfig::new()
.with_uppercase(true)
.with_prefix("0x");
let codec = HexCodec::from_config(config);
assert_eq!(codec.encode(&[0x1f, 0x8b]), "0x1F8B");Implementations§
Source§impl HexCodecConfig
impl HexCodecConfig
Sourcepub fn with_uppercase(self, uppercase: bool) -> Self
pub fn with_uppercase(self, uppercase: bool) -> Self
Sourcepub fn with_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_prefix(self, prefix: impl Into<String>) -> Self
Sourcepub fn with_byte_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_byte_prefix(self, prefix: impl Into<String>) -> Self
Sourcepub fn with_separator(self, separator: impl Into<String>) -> Self
pub fn with_separator(self, separator: impl Into<String>) -> Self
Sourcepub fn with_ignored_ascii_whitespace(self, ignore: bool) -> Self
pub fn with_ignored_ascii_whitespace(self, ignore: bool) -> Self
Sourcepub fn with_ignore_prefix_case(self, ignore: bool) -> Self
pub fn with_ignore_prefix_case(self, ignore: bool) -> Self
Sourcepub fn is_uppercase(&self) -> bool
pub fn is_uppercase(&self) -> bool
Returns whether encoded digits use uppercase characters.
Sourcepub fn prefix(&self) -> Option<&str>
pub fn prefix(&self) -> Option<&str>
Returns the configured whole-output prefix.
§Returns
Some contains the prefix written before the encoded bytes; None
means no whole-output prefix is configured.
Sourcepub fn byte_prefix(&self) -> Option<&str>
pub fn byte_prefix(&self) -> Option<&str>
Returns the configured per-byte prefix.
§Returns
Some contains the prefix written before each encoded byte; None
means no per-byte prefix is configured.
Sourcepub fn separator(&self) -> Option<&str>
pub fn separator(&self) -> Option<&str>
Returns the configured separator.
§Returns
Some contains the separator written between bytes; None means no
separator is configured.
Sourcepub fn ignores_ascii_whitespace(&self) -> bool
pub fn ignores_ascii_whitespace(&self) -> bool
Returns whether ASCII whitespace is ignored while decoding.
Sourcepub fn ignores_prefix_case(&self) -> bool
pub fn ignores_prefix_case(&self) -> bool
Returns whether configured prefixes are matched case-insensitively.