Skip to main content

LatexDefinitionPayload

Struct LatexDefinitionPayload 

Source
pub struct LatexDefinitionPayload {
    pub kind: LatexDefinitionKind,
    pub name: String,
    pub source_name: String,
    pub args: usize,
    pub packed: bool,
    pub robust: bool,
    pub body_argument: bool,
    pub feature: Option<String>,
}
Expand description

The payload of flm.pres.latex.definition: a macro or environment definition, or a feature’s declaration (LatexDefinitionKind::Declaration), that the style file must hold for the recomposed LaTeX to compile.

The content slots hold the definition’s LaTeX as lowered content: body (BODY_SLOT) for a macro and a declaration, or BEGIN_SLOT and END_SLOT for an environment. The definition takes args arguments, all of them mandatory, and the body refers to them as #1 to #<args>; every call writes exactly that many groups, in that order, and nothing else, so LaTeX reads no argument syntax of its own at a call. An environment may take one more argument, its own body (body_argument); a call writes no group for that one, since what a call writes between \begin and \end is already the body.

The lowering rule that recomposes a kept user definition (kept) stages a definition node at every use site of the definition, since rules keep no state. The emitter writes nothing in the node’s place: it records the definition for the style file once per name, so that the style file holds it exactly once.

Fields§

§kind: LatexDefinitionKind

What the node defines: a macro, an environment or a feature’s declaration (LatexDefinitionKind).

§name: String

The name defined, without a backslash (flmUDhello, flmUEnote); for a declaration, the name of the control sequence it is guarded on (lemma, c@theorem).

§source_name: String

The name the document declared, without a backslash (hello, note), where it differs from name — a recomposed user definition is renamed under a prefix of its own (recomposed_name). The style file writes it in the comment line above the definition, so that an author reading the file recognizes their own definition. Equal to name unless with_source_name said otherwise, which is how a definition written under the document’s own name is told from one written under a prefix (is_bare).

§args: usize

How many arguments the definition takes. Any number: past PLAIN_ARGUMENT_LIMIT the call hands them over in one group (packed) rather than one group each.

§packed: bool

Whether the call hands the arguments over in one group instead of one group each: \<name>{{first}{second}…}, one pair of braces around each argument, in argument order.

This is how a definition of more than PLAIN_ARGUMENT_LIMIT arguments is written, since a LaTeX macro body can refer to only nine parameters. The definition then takes one LaTeX parameter regardless of args, and its body reads argument n out of it with the style file’s accessor (ARG_COMMAND, \flmArg{<n>}{#1}). A definition of nine effective arguments or fewer keeps the plain form, where the body refers to #1 to #<args> directly.

§robust: bool

Whether the definition is written as a robust command rather than as a plain expandable macro: the render option robust_names lists the name the document declared.

A robust command is one LaTeX writes into a file of its own — the table of contents, the auxiliary file — as the call itself rather than as what the call stands for, and runs when that file is read back. The macro is then written with the document command interface, \ProvideDocumentCommand\<name>{+m …} with one +m per argument (\DeclareDocumentCommand where the definition is written under the document’s own name, is_bare), where an expandable one is \providecommand\<name>[<n>]. The + makes each argument long, so it may hold a paragraph break, as \providecommand does of itself.

Only a macro carries this. An environment is robust however it is written — \begin opens a group, runs the begin code, sets the body and runs the end code, none of which expansion alone could produce — so the option changes nothing for one, and the projection refuses a payload that claims it (from_projection).

§body_argument: bool

Whether the definition takes what is written between \begin and \end as an argument of its own rather than letting LaTeX set it between the begin and the end code: the environment’s argument specification ends with +b, after one +m per argument, and the body is the last parameter — #<args + 1>, or #2 where the arguments are packed into one group.

An environment written this way carries its whole definition in the BEGIN_SLOT, with the body’s parameter written where the definition wants the body, and its END_SLOT is empty. This is how a definition is written that wants the body somewhere a begin code and an end code cannot put it — inside a command’s argument, or in two places.

Only an environment can take one: a macro’s body slot is its whole definition already, so LatexDefinitionKind::Macro leaves this false.

§feature: Option<String>

The feature that writes this definition from its own configuration, where the definition is not one the document declared: defterm for the environment of a defined term, whose begin code is the configured lead-in. None for a recomposed user definition.

Such a definition is written under the name it is given and always guarded — \providecommand, \ProvideDocumentEnvironment, the test \ifcsname around a declaration — like a definition piece, so that a definition of that name the user made before the style file is loaded wins; the style file writes it before the document’s own definitions, under a comment line that gives the feature’s name (RecomposedDefinition::feature). A feature stages one where the definition’s text must be lowered — a template of its configuration, written through the ordinary rules — which a definition piece, fixed text, cannot hold.

Implementations§

Source§

impl LatexDefinitionPayload

Source

pub fn new( kind: LatexDefinitionKind, name: impl Into<String>, args: usize, ) -> Self

A definition of kind named name taking args arguments, declared in the document under that same name and calling them one group each.

Source

pub fn of_feature(self, feature: impl Into<String>) -> Self

The same definition written by the feature feature from its own configuration (feature): guarded, under the name it is given.

Source

pub fn with_source_name(self, source_name: impl Into<String>) -> Self

The same definition declared in the document under source_name, the author’s own spelling, which the style file writes in the comment line above the definition (source_name).

Source

pub fn packed(self) -> Self

The same definition with its arguments handed over in one group (packed).

Source

pub fn robust(self) -> Self

The same definition written as a robust command (robust). A macro only: an environment is robust however it is written, and the projection refuses one that claims it.

Source

pub fn body_argument(self) -> Self

The same definition taking its body as its last argument (body_argument). An environment only: a macro has no body of its own to take, and the projection refuses one that claims it (from_projection).

Source

pub fn is_bare(&self) -> bool

Whether the definition is written under the name the document spelled rather than under a prefix of its own. The render option bare_names asked for it, so the definition is meant to replace any definition that LaTeX or a package makes under that name, and the emitter writes it unconditionally rather than guarded. A feature’s definition (feature) is never bare.

Source

pub fn from_projection( value: &SerialValue, ) -> Result<LatexDefinitionPayload, DeserializeError>

The payload rebuilt from its projection, the value project produced.

§Errors

Returns a DeserializeError that identifies flm.pres.latex.definition when the projection is not a map, when kind is missing or is not the name of a kind (LatexDefinitionKind::parse), when name is missing or is not a string, when source or feature is present and is not a string, when a declaration gives no feature, takes arguments or is packed, when args is present and is not a whole number of arguments, when packed, robust or body is present and is not a boolean, when body is set on anything but an environment (a macro’s body slot is already its whole definition), or when robust is set on anything but a macro (an environment is robust however it is written). Any number of arguments is accepted: past PLAIN_ARGUMENT_LIMIT the call hands them over in one group.

Trait Implementations§

Source§

impl Clone for LatexDefinitionPayload

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 LatexDefinitionPayload

Source§

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

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

impl Eq for LatexDefinitionPayload

Source§

impl PartialEq for LatexDefinitionPayload

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PresPayload for LatexDefinitionPayload

Source§

fn project(&self) -> SerialValue

Returns the payload as plain serialized data: what the projection prints and what the serialization writes. Read more
Source§

impl StructuralPartialEq for LatexDefinitionPayload

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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> 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.