pub struct QuoteEnvironment {
pub sections: BTreeSet<QuoteSection>,
pub bare: Option<QuoteSection>,
}Expand description
One quote environment: the quotation-section commands its body accepts, and the kind of quotation section its bare content (content written in the body outside any quotation-section command) is read as.
An environment accepts exactly the quotation-section commands of
sections, a set: the other commands are
not declared in its body, and the order of the set has no meaning (an
author writes the quotation sections in any order). Where
bare holds a kind, each run of bare content is
read as one quotation section of that kind; where it holds none, bare
content is an error (the condition
BareContent). An environment must accept a
quotation-section command or read bare content, or
QuoteConfig::validate refuses the configuration when the registry is
built.
The bare-content kind also decides how the body is laid out
(holds_blocks): as paragraphs and
blocks when it is Block or when there is none, so
that each quotation-section command is a block of its own; as inline
content when it is Text,
Lines or Attributed,
so that the quotation sections and the bare content form one run.
§Examples
use flm_core::stdlib::features::quote::{QuoteEnvironment, QuoteSection};
// A quotation of one passage and its attribution, nothing else.
let epigraph = QuoteEnvironment::new([QuoteSection::Text, QuoteSection::Attributed]);
assert!(epigraph.enables(QuoteSection::Attributed));
assert_eq!(epigraph.bare, None);
// An environment whose whole content is lines, as `address` is.
let verse = QuoteEnvironment::new([]).bare(QuoteSection::Lines);
assert!(!verse.holds_blocks());Fields§
§sections: BTreeSet<QuoteSection>The quotation-section commands the body accepts.
bare: Option<QuoteSection>The kind of quotation section bare content is read as; None makes
bare content an error.
Implementations§
Source§impl QuoteEnvironment
impl QuoteEnvironment
Sourcepub fn new(sections: impl IntoIterator<Item = QuoteSection>) -> QuoteEnvironment
pub fn new(sections: impl IntoIterator<Item = QuoteSection>) -> QuoteEnvironment
Returns an environment that accepts the quotation-section commands of
sections (a kind given twice is accepted once) and whose bare content
is an error. bare sets the kind bare
content is read as.
Sourcepub fn bare(self, kind: QuoteSection) -> QuoteEnvironment
pub fn bare(self, kind: QuoteSection) -> QuoteEnvironment
Builder: sets the kind of quotation section bare content is read as to
kind, and returns the environment.
Sourcepub fn enables(&self, section: QuoteSection) -> bool
pub fn enables(&self, section: QuoteSection) -> bool
Returns whether the body accepts the quotation-section command of the
kind section.
Sourcepub fn holds_blocks(&self) -> bool
pub fn holds_blocks(&self) -> bool
Returns whether the body is laid out as paragraphs and blocks: true
when its bare content is read as a Block
section or is an error. A body whose bare content is read as a passage,
lines or an attribution is laid out as inline content.
Trait Implementations§
Source§impl Clone for QuoteEnvironment
impl Clone for QuoteEnvironment
Source§impl Debug for QuoteEnvironment
impl Debug for QuoteEnvironment
Source§impl<'de> Deserialize<'de> for QuoteEnvironment
impl<'de> Deserialize<'de> for QuoteEnvironment
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 QuoteEnvironment
Source§impl Hash for QuoteEnvironment
impl Hash for QuoteEnvironment
Source§impl JsonSchema for QuoteEnvironment
impl JsonSchema for QuoteEnvironment
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 QuoteEnvironment
impl PartialEq for QuoteEnvironment
Source§impl Serialize for QuoteEnvironment
impl Serialize for QuoteEnvironment
impl StructuralPartialEq for QuoteEnvironment
Auto Trait Implementations§
impl Forget for QuoteEnvironment
impl Freeze for QuoteEnvironmentwhere
*const LeafNode<QuoteSection, SetValZST> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(QuoteSection, SetValZST)>>: Freeze,
impl Move for QuoteEnvironment
impl RefUnwindSafe for QuoteEnvironment
impl Send for QuoteEnvironmentwhere
NodeRef<Owned, QuoteSection, SetValZST, LeafOrInternal>: Send,
BoxRaw<(QuoteSection, SetValZST)>: Send,
impl Sync for QuoteEnvironmentwhere
NodeRef<Owned, QuoteSection, SetValZST, LeafOrInternal>: Sync,
BoxRaw<(QuoteSection, SetValZST)>: Sync,
impl Unpin for QuoteEnvironmentwhere
*const LeafNode<QuoteSection, SetValZST> is !null: Unpin,
Box<(QuoteSection, SetValZST)>: Unpin,
impl UnsafeUnpin for QuoteEnvironmentwhere
*const LeafNode<QuoteSection, SetValZST> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(QuoteSection, SetValZST)>>: UnsafeUnpin,
impl UnwindSafe for QuoteEnvironment
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