Skip to main content

EnvironmentBuilder

Struct EnvironmentBuilder 

Source
pub struct EnvironmentBuilder { /* private fields */ }
Expand description

Accumulates an environment definition and installs it via def_environment — the environment analog of ConstructorBuilder, sharing the same option machinery. The prototype is the DefEnvironment! shape: "{name}" or "{name}{}…" (env name in braces, then the parameter list).

Implementations§

Source§

impl EnvironmentBuilder

Source

pub fn new(proto: &str) -> Result<Self>

Parse the {name}<params> prototype (mirrors the DefEnvironmentWO! macro: extract the braced name, parse the remainder as parameters against a synthetic \name control sequence).

Source

pub fn replacement(self, repl: ReplacementClosure) -> Self

Set the XML replacement (typically referencing #body).

Source

pub fn set_option(self, key: &str, value: OptionValue) -> Result<Self>

Apply a scalar option by name (shared map: apply_scalar_option).

Source

pub fn after_digest(self, hook: DigestionClosure) -> Self

Push an afterDigest hook (constructor: after digestion; environment: runs on the \end whatsit — Perl semantics).

Source

pub fn after_digest_begin(self, hook: DigestionClosure) -> Self

Push an afterDigestBegin hook (environments: runs on the \begin whatsit right after its arguments digest).

Source

pub fn after_digest_body(self, hook: DigestionClosure) -> Self

Push an afterDigestBody hook (environments / box constructors: runs on the whatsit after the captured body digests — Perl’s afterDigestBody).

Source

pub fn before_digest(self, hook: BeforeDigestClosure) -> Self

Push a beforeDigest hook (runs before the arguments are digested — Perl’s beforeDigest => sub {…}, e.g. \footnote’s neutralize_font).

Source

pub fn before_digest_end(self, hook: BeforeDigestClosure) -> Self

Push a beforeDigestEnd hook (environments: before \end{…} digests).

Source

pub fn before_construct(self, hook: ConstructionClosure) -> Self

Push a beforeConstruct hook (runs before the replacement absorbs).

Source

pub fn after_construct(self, hook: ConstructionClosure) -> Self

Push an afterConstruct hook (runs after the replacement absorbs).

Source

pub fn properties(self, props: PropertiesClosure) -> Self

Set the properties closure (computes the whatsit’s property map from the digested args — Perl’s properties => sub {…} / properties => {…}).

Source

pub fn reversion(self, rev: Reversion) -> Self

Set the reversion (reversion => "…" token form or a closure).

Source

pub fn font(self, font: FontDirective) -> Self

Set the font directive (font => { family => …, … }).

Source

pub fn sizer(self, sizer: SizingClosure) -> Self

Set the sizer (sizer => sub {…} computing (width, height, depth)).

Source

pub fn install(self) -> Result<()>

Install the accumulated environment definition.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.