pub use crate::safe_mode::SafeMode;
use crate::{AttributeValue, DocumentAttributes};
#[derive(Debug, Clone, Default)]
#[non_exhaustive]
pub struct Options {
pub safe_mode: SafeMode,
pub timings: bool,
pub document_attributes: DocumentAttributes,
pub strict: bool,
#[cfg(feature = "setext")]
pub setext: bool,
}
impl Options {
#[must_use]
pub fn builder() -> OptionsBuilder {
OptionsBuilder::default()
}
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn with_attributes(document_attributes: DocumentAttributes) -> Self {
Self {
document_attributes,
..Default::default()
}
}
}
#[derive(Debug, Clone, Default)]
#[non_exhaustive]
pub struct OptionsBuilder {
safe_mode: SafeMode,
timings: bool,
document_attributes: DocumentAttributes,
strict: bool,
#[cfg(feature = "setext")]
setext: bool,
}
impl OptionsBuilder {
#[must_use]
pub fn with_safe_mode(mut self, safe_mode: SafeMode) -> Self {
self.safe_mode = safe_mode;
self
}
#[must_use]
pub fn with_timings(mut self) -> Self {
self.timings = true;
self
}
#[must_use]
pub fn with_strict(mut self) -> Self {
self.strict = true;
self
}
#[must_use]
pub fn with_attribute(
mut self,
name: impl Into<String>,
value: impl Into<AttributeValue>,
) -> Self {
self.document_attributes.insert(name.into(), value.into());
self
}
#[must_use]
pub fn with_attributes(mut self, document_attributes: DocumentAttributes) -> Self {
self.document_attributes = document_attributes;
self
}
#[cfg(feature = "setext")]
#[must_use]
pub fn with_setext(mut self) -> Self {
self.setext = true;
self
}
#[must_use]
pub fn build(self) -> Options {
Options {
safe_mode: self.safe_mode,
timings: self.timings,
document_attributes: self.document_attributes,
strict: self.strict,
#[cfg(feature = "setext")]
setext: self.setext,
}
}
}