Skip to main content

OptionsBuilder

Struct OptionsBuilder 

Source
#[non_exhaustive]
pub struct OptionsBuilder<'a> { /* private fields */ }
Expand description

Builder for Options that provides an API for configuration.

Create an OptionsBuilder using Options::builder().

§Example

use acdc_parser::{Options, SafeMode};

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

Implementations§

Source§

impl<'a> OptionsBuilder<'a>

Source

pub fn with_safe_mode(self, safe_mode: SafeMode) -> Self

Set the safe mode for parsing.

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

let options = Options::builder()
    .with_safe_mode(SafeMode::Safe)
    .build()?;
Source

pub fn with_timings(self) -> Self

Enable timing information during parsing.

§Example
use acdc_parser::Options;

let options = Options::builder()
    .with_timings()
    .build()?;
Source

pub fn with_include_loader(self, include_loader: IncludeLoader) -> Self

Select how the parser loads include sources.

Defaults to IncludeLoader::System. The default Secure mode prevents include reads even when a provider is supplied. Use IncludeLoader::Disabled to disable loading in lower modes, or IncludeLoader::custom to supply sources from an editor overlay, virtual filesystem, or custom transport.

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

let options = Options::builder()
    .with_safe_mode(SafeMode::Safe)
    .with_include_loader(IncludeLoader::System)
    .build()?;
Source

pub fn with_max_total_include_bytes(self, bytes: usize) -> Self

Set the total selected include text allowed per parse, in bytes.

Defaults to 64 MiB. Each selection counts after indent=, plus one byte for a separating newline if the text is not empty. This count precedes nested processing and removal of comments and inactive conditionals. Nested and repeated includes share the limit. The entry text does not count.

Zero permits only empty selections. Document attributes cannot change this limit. The 10 MiB per-include limit and safe-mode permissions still apply.

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

let options = Options::builder()
    .with_safe_mode(SafeMode::Safe)
    .with_max_total_include_bytes(256 * 1024 * 1024)
    .build()?;
Source

pub fn with_base_dir(self, base_dir: impl AsRef<Path>) -> Self

Set the directory used to resolve relative includes from the entry input.

Only takes effect when include loading is enabled. For file input this overrides the entry file’s parent directory. For string or reader input it overrides the current working directory. Nested includes remain relative to the file that contains them.

Source

pub fn with_strict(self) -> Self

Reject manpage titles that do not use the name(volume) form.

Other recoverable problems still produce warnings.

§Example
use acdc_parser::Options;

let options = Options::builder()
    .with_strict()
    .build()?;
Source

pub fn with_attribute( self, name: impl Into<Cow<'a, str>>, value: impl Into<AttributeValue<'a>>, ) -> Self

Supply an application attribute.

Application values take precedence over document entries, subject to the attribute’s standard assignment rules.

This is a convenience method that accepts various types for the value:

  • &str becomes AttributeValue::String
  • bool becomes AttributeValue::Bool
  • () becomes AttributeValue::None
§Example
use acdc_parser::Options;

let options = Options::builder()
    .with_attribute("toc", "left")
    .with_attribute("sectnums", true)
    .build()?;
Source

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

Replace the application-supplied attributes.

Source

pub fn with_defaults<N, V>( self, defaults: impl IntoIterator<Item = (N, V)>, ) -> Self
where N: Into<Cow<'a, str>>, V: Into<AttributeValue<'a>>,

Replace defaults for attributes not supplied by the application.

Document entries can replace these defaults when the attribute permits it. Intrinsic backend values retain their normal precedence. Backend, base backend, file type, and document type defaults also determine their convenience attributes when the options are built.

Source

pub fn with_default_attribute( self, name: impl Into<Cow<'a, str>>, value: impl Into<AttributeValue<'a>>, ) -> Self

Supply a default without changing an application override.

Source

pub fn attribute(&self, name: &str) -> Option<&AttributeValue<'a>>

Inspect a supplied override or default before validation.

Source

pub fn build(self) -> Result<Options<'a>, Error>

Build the Options from this builder.

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

let options = Options::builder()
    .with_safe_mode(SafeMode::Safe)
    .build()?;
§Errors

Returns a structured error for an invalid attribute value.

Trait Implementations§

Source§

impl<'a> Clone for OptionsBuilder<'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 OptionsBuilder<'a>

Source§

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

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

impl<'a> Default for OptionsBuilder<'a>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

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

§

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

§

impl<'a> Freeze for OptionsBuilder<'a>

§

impl<'a> Send for OptionsBuilder<'a>

§

impl<'a> Sync for OptionsBuilder<'a>

§

impl<'a> Unpin for OptionsBuilder<'a>

§

impl<'a> UnsafeUnpin for OptionsBuilder<'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