pub struct XnotesConfig {
pub kinds: Vec<XnoteKind>,
}Expand description
The configuration of the XnotesFeature: the xnote
kinds an author writes, in the order in which their lists are placed after
the content.
The default (XnotesConfig::new) declares one xnote kind,
XnoteKind::footnote: \footnote{…}, numbered, listed after the
content under the heading Footnotes. A second xnote kind is added by
configuration, with no new syntax:
use flm_core::stdlib::features::numbering::PrefixWords;
use flm_core::stdlib::features::xnotes::{XnoteKind, XnotesConfig};
let config = XnotesConfig::new().kind(
XnoteKind::numbered("endnote", PrefixWords::new("Endnote~", "Endnotes~"))
.commands(["endnote"])
.label_type("en"),
);
assert_eq!(config.kinds.len(), 2);
assert_eq!(config.validate(), Ok(()));XnotesFeature::new takes this value; the
standard features carry it as
StdlibConfig::xnotes. It is a
feature’s configuration: fixed when the registry is built, before any
document is parsed (see settings, options and
configuration),
because the commands are part of the language, whether an xnote is a block
is decided before a document’s trees are frozen (no longer changed; see
frozen
trees),
and the counters and
counter styles the feature declares depend on it. The feature therefore
adds digest_bytes to the registry digest,
the fingerprint that decides whether a cached result may be reused.
The configuration is checked when the registry is built
(XnotesConfig::validate): every xnote kind on its own
(XnoteKind::validate), then two kinds of one name, two kinds sharing a
command, and two kinds sharing a label type are refused. A kind with no
command is accepted; no author can write its xnotes. A kind that another
feature contributes (contribute_kind) is
checked on its own only: nothing refuses that it shares a label type with
a configured kind.
Fields§
§kinds: Vec<XnoteKind>The xnote kinds, in the order in which their lists are placed.
Implementations§
Source§impl XnotesConfig
impl XnotesConfig
Sourcepub fn new() -> XnotesConfig
pub fn new() -> XnotesConfig
The default configuration: a single xnote kind, XnoteKind::footnote.
Sourcepub fn empty() -> XnotesConfig
pub fn empty() -> XnotesConfig
A configuration declaring no xnote kind at all.
Sourcepub fn kind(self, kind: XnoteKind) -> XnotesConfig
pub fn kind(self, kind: XnoteKind) -> XnotesConfig
Builder: adds the xnote kind kind after the kinds already declared.
Sourcepub fn kind_named(&self, name: &str) -> Option<&XnoteKind>
pub fn kind_named(&self, name: &str) -> Option<&XnoteKind>
The declared xnote kind named name, if there is one.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Checks the configuration; the feature calls it when it registers.
§Errors
A sentence describing the first problem found: one of
XnoteKind::validate’s, or two xnote kinds of one name, sharing a
command, or sharing a label type.
Sourcepub fn digest_bytes(&self) -> Vec<u8> ⓘ
pub fn digest_bytes(&self) -> Vec<u8> ⓘ
The canonical rendering of the configuration: what enters the registry
digest, and what Hash hashes.
Every xnote kind is written out in order, every field of it, each text preceded by its length, so two configurations give the same bytes exactly when they are equal. Fields that have no effect (an unnumbered kind’s number format) are written too: a digest that differs where nothing else does only prevents the reuse of a cached result, and never produces a wrong one.
Trait Implementations§
Source§impl Clone for XnotesConfig
impl Clone for XnotesConfig
Source§impl Debug for XnotesConfig
impl Debug for XnotesConfig
Source§impl Default for XnotesConfig
impl Default for XnotesConfig
Source§fn default() -> XnotesConfig
fn default() -> XnotesConfig
Source§impl<'de> Deserialize<'de> for XnotesConfigwhere
XnotesConfig: Default,
impl<'de> Deserialize<'de> for XnotesConfigwhere
XnotesConfig: Default,
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 XnotesConfig
Source§impl Hash for XnotesConfig
impl Hash for XnotesConfig
Source§impl JsonSchema for XnotesConfig
impl JsonSchema for XnotesConfig
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 PartialEq for XnotesConfig
impl PartialEq for XnotesConfig
impl StructuralPartialEq for XnotesConfig
Auto Trait Implementations§
impl Forget for XnotesConfig
impl Freeze for XnotesConfig
impl Move for XnotesConfig
impl RefUnwindSafe for XnotesConfig
impl Send for XnotesConfig
impl Sync for XnotesConfig
impl Unpin for XnotesConfig
impl UnsafeUnpin for XnotesConfig
impl UnwindSafe for XnotesConfig
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