pub struct AnnotationsConfig {
pub annotators: Vec<Annotator>,
}Expand description
The configuration of the annotations feature: the annotators, in order.
Each annotator declares one command, written in three forms: \phf{…}
and \phf … \endphf mark a passage (a highlight), and \phf[…]
writes a remark (a comment). The order numbers the annotators from
zero; an output that shows colors chooses one per number. The default
configuration declares no annotator, and the feature then declares no
command at all: \phf is an unknown command until a host configures it.
§Examples
use flm_core::stdlib::features::annotations::{AnnotationsConfig, Annotator};
let config = AnnotationsConfig::new()
.annotator(Annotator::new("phf").initials("PhF"))
.annotator(Annotator::new("abc"));
assert_eq!(config.annotators.len(), 2);
assert_eq!(config.number_of("abc"), Some(1));
assert_eq!(config.validate(), Ok(()));
assert!(AnnotationsConfig::new().annotators.is_empty());The value is what
AnnotationsFeature::new takes; a host
using the standard features passes it with
StdlibConfig::annotations.
The configuration is fixed when the registry is built, before any document
is parsed
(configuration),
because the commands are part of the language. The feature therefore
feeds digest_bytes into the registry
digest (digests), the fingerprint that decides
whether a cached result may be reused.
The feature checks the configuration when the registry is built
(AnnotationsConfig::validate): every annotator on its own
(Annotator::validate), then two annotators with the same command are
refused. A command that another feature also declares, such as emph,
makes the registry build fail, as any two declarations of one name do.
The configuration refers to no output, HTML tag or class. Whether
annotations are shown at all is decided per render, not by the
configuration: AnnotationsRenderOptions.
Fields§
§annotators: Vec<Annotator>The annotators, in order: the first is annotator 0. In settings, a map from each annotator’s command name to its other fields.
Implementations§
Source§impl AnnotationsConfig
impl AnnotationsConfig
Sourcepub fn new() -> AnnotationsConfig
pub fn new() -> AnnotationsConfig
Returns the default configuration: no annotator.
Sourcepub fn annotator(self, annotator: Annotator) -> AnnotationsConfig
pub fn annotator(self, annotator: Annotator) -> AnnotationsConfig
Builder: adds annotator after the annotators already declared, and
returns the configuration; the new annotator’s number is the count of
those already declared.
Sourcepub fn number_of(&self, command: &str) -> Option<usize>
pub fn number_of(&self, command: &str) -> Option<usize>
Returns the number of the annotator whose command is command, or
None when there is none.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Checks the configuration, as the feature does when it registers.
§Errors
Returns a sentence that states the first problem found: one of
Annotator::validate’s, or two annotators with the same command.
Sourcepub fn digest_bytes(&self) -> Vec<u8> ⓘ
pub fn digest_bytes(&self) -> Vec<u8> ⓘ
Returns the canonical byte form of the configuration, which the feature feeds into the registry digest: every annotator in order, every field of it, each text preceded by its length. Two configurations therefore have the same byte form exactly when they are equal.
Trait Implementations§
Source§impl Clone for AnnotationsConfig
impl Clone for AnnotationsConfig
Source§impl Debug for AnnotationsConfig
impl Debug for AnnotationsConfig
Source§impl Default for AnnotationsConfig
impl Default for AnnotationsConfig
Source§impl<'de> Deserialize<'de> for AnnotationsConfigwhere
AnnotationsConfig: Default,
impl<'de> Deserialize<'de> for AnnotationsConfigwhere
AnnotationsConfig: 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 AnnotationsConfig
Source§impl Hash for AnnotationsConfig
impl Hash for AnnotationsConfig
Source§impl JsonSchema for AnnotationsConfig
impl JsonSchema for AnnotationsConfig
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 AnnotationsConfig
impl PartialEq for AnnotationsConfig
impl StructuralPartialEq for AnnotationsConfig
Auto Trait Implementations§
impl Forget for AnnotationsConfig
impl Freeze for AnnotationsConfig
impl Move for AnnotationsConfig
impl RefUnwindSafe for AnnotationsConfig
impl Send for AnnotationsConfig
impl Sync for AnnotationsConfig
impl Unpin for AnnotationsConfig
impl UnsafeUnpin for AnnotationsConfig
impl UnwindSafe for AnnotationsConfig
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