Skip to main content

Options

Struct Options 

Source
#[non_exhaustive]
pub struct Options<'a> { pub safe_mode: SafeMode, pub timings: bool, pub include_loader: IncludeLoader, pub base_dir: Option<PathBuf>, pub strict: bool, /* private fields */ }

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§safe_mode: SafeMode

Defaults to SafeMode::Secure, which prevents include reads.

§timings: bool§include_loader: IncludeLoader

Selects how the parser loads include sources.

Defaults to IncludeLoader::System, subject to safe_mode. Set IncludeLoader::Disabled to preserve directives in modes below Secure.

§base_dir: Option<PathBuf>

Directory used to resolve relative includes from the entry input.

Only consulted when include loading is enabled. String and reader input default to the current working directory. File input normally uses the entry file’s parent, unless this value overrides it. In Safe and Server modes this directory is also the local-include boundary.

§strict: bool

Reject a manpage title that does not use the name(volume) form.

This does not promote all warnings to errors. Use crate::ParseResult::source_recovery to detect recovered content.

Implementations§

Source§

impl<'a> Options<'a>

Source

pub fn builder() -> OptionsBuilder<'a>

Create a new OptionsBuilder for fluent configuration.

§Example
use acdc_parser::{Options, SafeMode};

let options = Options::builder()
    .with_safe_mode(SafeMode::Safe)
    .with_timings()
    .with_attribute("toc", "left")
    .build()?;
Source

pub fn new() -> Self

Create a new Options with default settings.

Equivalent to Options::default().

Source

pub fn with_attributes<N, V>( attributes: impl IntoIterator<Item = (N, V)>, ) -> Result<Self, Error>
where N: Into<Cow<'a, str>>, V: Into<AttributeValue<'a>>,

Create options from application-supplied attributes.

§Errors

Returns a structured error for an invalid attribute value.

Source

pub const fn document_attributes(&self) -> &DocumentAttributes<'a>

Return the validated attributes configured for parsing.

Source

pub fn max_total_include_bytes(&self) -> usize

Maximum selected include text per parse, in bytes. Defaults to 64 MiB.

See OptionsBuilder::with_max_total_include_bytes for what counts.

Source

pub fn into_document_attributes(self) -> DocumentAttributes<'a>

Consume the options and return their validated attribute collection.

Source

pub fn with_document_attributes( self, attributes: DocumentAttributes<'a>, ) -> Self

Replace the attribute snapshot with one from an already parsed document.

This does not reclassify or revalidate assignments. Use the builder when supplied values should become new application overrides.

Source

pub fn into_builder(self) -> OptionsBuilder<'a>

Reopen configuration while preserving application overrides and defaults.

Source

pub fn into_static(self) -> Options<'static>

Consume the options, producing an independent 'static copy.

Trait Implementations§

Source§

impl<'a> Clone for Options<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Options<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Options<'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Options<'a>

§

impl<'a> !UnwindSafe for Options<'a>

§

impl<'a> Freeze for Options<'a>

§

impl<'a> Send for Options<'a>

§

impl<'a> Sync for Options<'a>

§

impl<'a> Unpin for Options<'a>

§

impl<'a> UnsafeUnpin for Options<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more