Skip to main content

BodyDef

Struct BodyDef 

Source
pub struct BodyDef {
    pub layout: BodyLayout,
    pub parser: Option<Arc<dyn FlmBodyParser>>,
    pub mode: Option<Mode>,
    pub opaque_wrapper: bool,
    pub scoped: Vec<Name>,
    pub events: Vec<FlmEvent>,
}
Expand description

The declaration of an environment’s body: how it is laid out, which parser reads it, which parsing mode it is read in, whether its content is kept as written under an opaque wrapper, which scoped packages are available inside it, and which state events it is read under.

BodyDef::new (the same as BodyDef::default()) declares a body laid out by the element’s block role, read the ordinary way, read in the mode the environment is written in, with no opaque wrapper, with no scoped package and with no event; each builder method changes one of these.

The body parser is one field among the others (BodyDef::parser): a body that is not read the ordinary way (raw text, or content a feature checks as it reads it) holds the object that reads it, and minting applies the layout, mode, opaque wrapper, scoped packages and events declared here around that object.

Fields§

§layout: BodyLayout

How the block-structure pass lays out the body.

§parser: Option<Arc<dyn FlmBodyParser>>

The parser that reads the body, when the body is not read the ordinary way (content up to and including \end{name}). See BodyDef::parser.

§mode: Option<Mode>

The parsing mode the body is read in: Some(Mode::Math) for an equation-like environment, Some(Mode::Text) to restore the non-mathematics context that encloses the mathematics, None to read the body in the mode the environment is written in.

§opaque_wrapper: bool

Whether minting places the body’s content under an opaque wrapper, as ArgDef::opaque_wrapper does for an argument: a group of the class FlmGroupType::OpaqueWrapper, whose content the block-structure pass carries over as written. The wrapper is placed around whatever reads the body, the declared parser or the ordinary reading, and the content designated as the body’s stays the same nodes. false by default; set it with BodyDef::with_opaque_wrapper.

A body declared with an opaque wrapper may not declare a layout other than BodyLayout::FromRole; minting reports one as MintError::LayoutOnOpaqueWrappedBody. A scoped package declared on it is attached as on any body (BodyDef::scoped).

§scoped: Vec<Name>

The names of the scoped packages whose declarations are available inside this body, such as the package that defines \item inside a list environment. See BodyDef::scoped.

§events: Vec<FlmEvent>

The state events the body is read under (FlmEvent), in the order they are declared; empty by default. See BodyDef::event.

Implementations§

Source§

impl BodyDef

Source

pub fn new() -> BodyDef

Creates the declaration of a body read the ordinary way, laid out by the element’s block role (BodyLayout::FromRole), read in the mode the environment is written in, with no opaque wrapper, no scoped package and no event. The same as BodyDef::default().

Source

pub fn layout(self, layout: BodyLayout) -> BodyDef

Builder: sets how the body is laid out.

Source

pub fn blocks(self) -> BodyDef

Builder: the body is a region of blocks; shorthand for .layout(BodyLayout::Blocks).

Source

pub fn verbatim(self) -> BodyDef

Builder: the body is raw text, read by FLM’s verbatim reader (crate::lang::verbatim), which places the content under a group of the verbatim class; shorthand for .parser(FlmVerbatimBehavior::new()).

Source

pub fn parser(self, parser: impl IntoFlmBodyParser) -> BodyDef

Builder: sets the parser that reads the body (FlmBodyParser), for a body not read the ordinary way: FLM’s verbatim reader (BodyDef::verbatim), or a feature’s own parser, such as one that reads the ordinary content and then checks it.

Only the parser’s reading of the body is used: the environment’s arguments are those of the declaration, the body is read under the mode, the scoped packages and the events declared here, and what the parser read is placed under an opaque wrapper when the declaration asks for one (BodyDef::with_opaque_wrapper).

parser is a parser passed by value, or one already shared as Arc<dyn FlmBodyParser> by several declarations; IntoFlmBodyParser converts both.

Source

pub fn mode(self, mode: Mode) -> BodyDef

Builder: sets the parsing mode the body is read in. Mode::Math and Mode::Text mean what they mean for an argument (ArgDef::mode).

Source

pub fn with_opaque_wrapper(self) -> BodyDef

Builder: places the body’s content under an opaque wrapper (BodyDef::opaque_wrapper, which states what the wrapper does and what the declaration then admits).

Source

pub fn scoped(self, package: impl Into<Name>) -> BodyDef

Builder: makes the declarations of one more scoped package, given by name, available inside the body. Some feature must declare a ScopedPackageDef of that name; the rules are those of ArgDef::scoped.

Source

pub fn event(self, event: FlmEvent) -> BodyDef

Builder: adds one more state event (FlmEvent) that the body is read under, after those declared before; the rules are those of ArgDef::event.

An environment whose body declares FlmEvent::StandardState holds ordinary document content wherever it is written, even in a document parsed from a restricted state:

use flm_core::lang::FlmEvent;
use flm_core::lang::mint::BodyDef;

let body = BodyDef::new().blocks().event(FlmEvent::StandardState);
assert_eq!(body.events, [FlmEvent::StandardState]);

Trait Implementations§

Source§

impl Clone for BodyDef

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 Debug for BodyDef

Source§

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

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

impl Default for BodyDef

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for BodyDef

§

impl !UnwindSafe for BodyDef

§

impl Forget for BodyDef

§

impl Freeze for BodyDef

§

impl Move for BodyDef

§

impl Send for BodyDef
where Arc<dyn FlmBodyParser>: Send, RawVecInner: Send, Arc<str>: Send,

§

impl Sync for BodyDef
where Arc<dyn FlmBodyParser>: Sync, RawVecInner: Sync, Arc<str>: Sync,

§

impl Unpin for BodyDef
where Arc<dyn FlmBodyParser>: Unpin, *const u8 is !null: Unpin, Arc<str>: Unpin,

§

impl UnsafeUnpin for BodyDef

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

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.