pub struct HeadingCommand {
pub name: String,
pub heading: Name,
pub defaults: Vec<(String, String)>,
}Expand description
The declaration of a heading command.
A heading command is a macro, such as \section, that an author writes to
create a heading. The headings written with a heading command are of one
heading kind (HeadingDecl). A heading command can be declared with
default values for the options numbered and toc of these headings.
Headings of the same kind can be written with several heading commands. All
heading commands take the same arguments (heading_args), so two commands
of one kind differ only in their default options. The default options are
applied before the star and the key-value argument of the heading. An author
can therefore change them with the star and the key-value argument (see the
options of a heading).
The key of each default option must be NUMBERED_KEY or TOC_KEY, and
its value must be true or false. Otherwise, the registry build fails
(HeadingsConfig::validate).
§Examples
use flm_core::stdlib::features::headings::HeadingCommand;
// A heading written with `\quietsection{…}` is a section that is not listed
// in the table of contents, unless the heading is written with `toc=true`.
let quiet = HeadingCommand::new("quietsection", "section").default_value("toc", "false");
assert_eq!(quiet.defaults, [(String::from("toc"), String::from("false"))]);Fields§
§name: StringThe name of the command without the backslash, such as section. In
settings data, the name is the key of the entry and not a field.
heading: NameThe name of the heading kind of the headings written with the command.
defaults: Vec<(String, String)>The default options of the headings written with this command, as key-value pairs. They are applied in order, before the star and the key-value argument of the heading.
Implementations§
Source§impl HeadingCommand
impl HeadingCommand
Sourcepub fn new(name: impl Into<String>, heading: impl Into<Name>) -> HeadingCommand
pub fn new(name: impl Into<String>, heading: impl Into<Name>) -> HeadingCommand
Returns the heading command name, with which headings of the kind
heading are written, without default options.
Sourcepub fn default_value(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> HeadingCommand
pub fn default_value( self, key: impl Into<String>, value: impl Into<String>, ) -> HeadingCommand
Adds the default option key=value. It is applied after the default
options added before it.
Trait Implementations§
Source§impl Clone for HeadingCommand
impl Clone for HeadingCommand
Source§impl Debug for HeadingCommand
impl Debug for HeadingCommand
Source§impl<'de> Deserialize<'de> for HeadingCommand
impl<'de> Deserialize<'de> for HeadingCommand
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for HeadingCommand
Source§impl JsonSchema for HeadingCommand
impl JsonSchema for HeadingCommand
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl NamedEntry for HeadingCommand
In settings data, a heading command is an entry of the map
HeadingsConfig::commands, with the name of the command as its key.
impl NamedEntry for HeadingCommand
In settings data, a heading command is an entry of the map
HeadingsConfig::commands, with the name of the command as its key.
Source§fn read_entry(name: &str, data: Value) -> Result<HeadingCommand, String>
fn read_entry(name: &str, data: Value) -> Result<HeadingCommand, String>
Source§impl PartialEq for HeadingCommand
impl PartialEq for HeadingCommand
Source§impl Serialize for HeadingCommand
impl Serialize for HeadingCommand
impl StructuralPartialEq for HeadingCommand
Auto Trait Implementations§
impl Forget for HeadingCommand
impl Freeze for HeadingCommand
impl Move for HeadingCommand
impl RefUnwindSafe for HeadingCommand
impl Send for HeadingCommand
impl Sync for HeadingCommand
impl Unpin for HeadingCommand
impl UnsafeUnpin for HeadingCommandwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
PhantomData<(String, String)>: UnsafeUnpin,
impl UnwindSafe for HeadingCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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