#[must_use]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HexCodecConfig {
pub(crate) uppercase: bool,
pub(crate) prefix: Option<String>,
pub(crate) byte_prefix: Option<String>,
pub(crate) separator: Option<String>,
pub(crate) ignore_ascii_whitespace: bool,
pub(crate) ignore_prefix_case: bool,
}
impl HexCodecConfig {
#[inline]
pub fn new() -> Self {
Self {
uppercase: false,
prefix: None,
byte_prefix: None,
separator: None,
ignore_ascii_whitespace: false,
ignore_prefix_case: false,
}
}
#[inline]
pub fn with_uppercase(mut self, uppercase: bool) -> Self {
self.uppercase = uppercase;
self
}
#[inline]
pub fn with_prefix(mut self, prefix: impl Into<String>) -> Self {
self.prefix = Some(prefix.into());
self
}
#[inline]
pub fn with_byte_prefix(mut self, prefix: impl Into<String>) -> Self {
self.byte_prefix = Some(prefix.into());
self
}
#[inline]
pub fn with_separator(mut self, separator: impl Into<String>) -> Self {
self.separator = Some(separator.into());
self
}
#[inline]
pub fn with_ignored_ascii_whitespace(mut self, ignore: bool) -> Self {
self.ignore_ascii_whitespace = ignore;
self
}
#[inline]
pub fn with_ignore_prefix_case(mut self, ignore: bool) -> Self {
self.ignore_prefix_case = ignore;
self
}
#[must_use]
#[inline]
pub fn is_uppercase(&self) -> bool {
self.uppercase
}
#[must_use]
#[inline]
pub fn prefix(&self) -> Option<&str> {
self.prefix.as_deref()
}
#[must_use]
#[inline]
pub fn byte_prefix(&self) -> Option<&str> {
self.byte_prefix.as_deref()
}
#[must_use]
#[inline]
pub fn separator(&self) -> Option<&str> {
self.separator.as_deref()
}
#[must_use]
#[inline]
pub fn ignores_ascii_whitespace(&self) -> bool {
self.ignore_ascii_whitespace
}
#[must_use]
#[inline]
pub fn ignores_prefix_case(&self) -> bool {
self.ignore_prefix_case
}
}
impl Default for HexCodecConfig {
#[inline]
fn default() -> Self {
Self::new()
}
}