pub struct FloatsConfig {
pub types: Vec<FloatType>,
}Expand description
The configuration of the Floats feature: the float
types it declares, in order.
The default (FloatsConfig::new) declares the two shipped types,
figure and table, both
numbered. A caller replaces a type by declaring one of the same name
(float_type), removes one
(without_type), adds its own, or starts
from FloatsConfig::empty:
use flm_core::stdlib::features::floats::{FloatNumbering, FloatType, FloatsConfig};
let config = FloatsConfig::new()
.float_type(FloatType::figure().numbering(FloatNumbering::Numbered))
.float_type(FloatType::new("diagram", ["any"]));
assert_eq!(config.types.len(), 3);
assert!(config.validate().is_ok());A float type is document structure (a numbered series and the word under
its content), not a property of the content that fills it. The two shipped
types are therefore declared here, and they refer to the content handlers
they accept by name. A feature that brings a float type together with its
own content declares the type through
contribute_type instead.
The value is what Floats::new takes; the standard
package takes it through
StdlibConfig::floats. It is a
configuration, fixed when the registry is built: the environments are part
of the language, and the counters and counter styles are built from it. The
feature therefore adds digest_bytes to the
registry digest. The feature checks it when it registers
(validate).
Fields§
§types: Vec<FloatType>The float types, in order; no two have the same name. In settings, a map from each type’s name to its fields.
Implementations§
Source§impl FloatsConfig
impl FloatsConfig
Sourcepub fn new() -> FloatsConfig
pub fn new() -> FloatsConfig
Returns the configuration with the two shipped types, figure then
table.
Sourcepub fn empty() -> FloatsConfig
pub fn empty() -> FloatsConfig
Returns a configuration that declares no float type.
Sourcepub fn float_type(self, float_type: FloatType) -> FloatsConfig
pub fn float_type(self, float_type: FloatType) -> FloatsConfig
Builder: declares float_type, replacing the type of that name in
its place if there is one, and adding it at the end otherwise.
Sourcepub fn without_type(self, name: &str) -> FloatsConfig
pub fn without_type(self, name: &str) -> FloatsConfig
Builder: removes the type name, if there is one.
Sourcepub fn get(&self, name: &str) -> Option<&FloatType>
pub fn get(&self, name: &str) -> Option<&FloatType>
Returns the type name, if the configuration declares it.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Checks the configuration, as the feature does when it registers.
§Errors
A sentence that describes the first problem found: a type that fails
FloatType::validate, or two types of one name.
Sourcepub fn digest_bytes(&self) -> Vec<u8> ⓘ
pub fn digest_bytes(&self) -> Vec<u8> ⓘ
Returns the configuration written out as bytes: what the feature adds
to the registry digest, and what Hash hashes.
Every type is written out in order, with every one of its fields, each text preceded by its length. Two configurations give the same bytes exactly when they are equal. The code takes the fields apart by name, so a field added to a type and not written here fails to compile.
Trait Implementations§
Source§impl Clone for FloatsConfig
impl Clone for FloatsConfig
Source§impl Debug for FloatsConfig
impl Debug for FloatsConfig
Source§impl Default for FloatsConfig
impl Default for FloatsConfig
Source§fn default() -> FloatsConfig
fn default() -> FloatsConfig
Source§impl<'de> Deserialize<'de> for FloatsConfigwhere
FloatsConfig: Default,
impl<'de> Deserialize<'de> for FloatsConfigwhere
FloatsConfig: 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 FloatsConfig
Source§impl Hash for FloatsConfig
impl Hash for FloatsConfig
Source§impl JsonSchema for FloatsConfig
impl JsonSchema for FloatsConfig
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 FloatsConfig
impl PartialEq for FloatsConfig
impl StructuralPartialEq for FloatsConfig
Auto Trait Implementations§
impl Forget for FloatsConfig
impl Freeze for FloatsConfig
impl Move for FloatsConfig
impl RefUnwindSafe for FloatsConfig
impl Send for FloatsConfigwhere
RawVecInner: Send,
Arc<str>: Send,
NodeRef<Owned, String, PluralWords, LeafOrInternal>: Send,
BoxRaw<(String, PluralWords)>: Send,
impl Sync for FloatsConfigwhere
RawVecInner: Sync,
Arc<str>: Sync,
NodeRef<Owned, String, PluralWords, LeafOrInternal>: Sync,
BoxRaw<(String, PluralWords)>: Sync,
impl Unpin for FloatsConfig
impl UnsafeUnpin for FloatsConfig
impl UnwindSafe for FloatsConfig
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