pub struct WriteCx<'a> { /* private fields */ }Expand description
The writing context of a number writer: the counter style’s data, the library’s operations that build content, the within-joiner on demand, and the default writer to delegate to.
Everything a reader sees is content, not characters, and a writer builds content only through this context.
Implementations§
Source§impl<'a> WriteCx<'a>
impl<'a> WriteCx<'a>
Sourcepub fn style(&self) -> &'a CounterStyle
pub fn style(&self) -> &'a CounterStyle
Returns the counter style in which every value of this call is written.
Sourcepub fn word(
&self,
count: usize,
variant: Option<&str>,
) -> Option<&'a Arc<NodeTree<Flm>>>
pub fn word( &self, count: usize, variant: Option<&str>, ) -> Option<&'a Arc<NodeTree<Flm>>>
Returns the word written before count numbers in the variant
variant of the prefix words, or None when that word is the empty
text and nothing is written. A variant the counter style does not
declare gives the default words.
Sourcepub fn open(&self) -> &'a Arc<NodeTree<Flm>> ⓘ
pub fn open(&self) -> &'a Arc<NodeTree<Flm>> ⓘ
Returns the counter style’s opening delimiter, the text written before a number.
Sourcepub fn close(&self) -> &'a Arc<NodeTree<Flm>> ⓘ
pub fn close(&self) -> &'a Arc<NodeTree<Flm>> ⓘ
Returns the counter style’s closing delimiter, the text written after a number.
Sourcepub fn name_in_link(&self) -> bool
pub fn name_in_link(&self) -> bool
Returns whether the counter style says that the word written before
several numbers belongs to the link to the first number written. A
writer that writes a word itself marks it with the position of the first
number it writes when this is true, and with none when it is false.
For one value written with format, the default
writer makes the whole text one link regardless of this setting.
Sourcepub fn repeat_parents_in_range(&self) -> bool
pub fn repeat_parents_in_range(&self) -> bool
Returns whether the counter style says that the end of a range repeats
the parts that come from the counters the value is numbered within:
A.I–A.III instead of A.I–III. A writer that builds a range itself
decides with this whether to write the end’s parts again.
Sourcepub fn ranges(&self) -> bool
pub fn ranges(&self) -> bool
Returns whether the counter style says that consecutive numbers
collapse into a range (1–3) instead of each being written separately
(1,2,3). A writer that builds ranges itself decides with this whether
to build any.
Sourcepub fn join_text(&self, which: JoinText) -> &'a Arc<NodeTree<Flm>> ⓘ
pub fn join_text(&self, which: JoinText) -> &'a Arc<NodeTree<Flm>> ⓘ
Returns the counter style’s join text which.
Sourcepub fn number(
&self,
value: &CounterValue,
) -> Result<Arc<NodeTree<Flm>>, FormatError>
pub fn number( &self, value: &CounterValue, ) -> Result<Arc<NodeTree<Flm>>, FormatError>
Returns value written with the counter style’s own number template,
with its sub-numbers: the number alone, with no word, no delimiters and
nothing of the counters it is numbered within.
§Errors
FormatError::UndeclaredSubLevel when the value carries a sub-number
at a level the counter style declares no format for, and a failure to
build the content.
Sourcepub fn number_in(
&self,
value: &CounterValue,
format: NumberFormat,
) -> Result<Arc<NodeTree<Flm>>, FormatError>
pub fn number_in( &self, value: &CounterValue, format: NumberFormat, ) -> Result<Arc<NodeTree<Flm>>, FormatError>
Sourcepub fn number_of_in(
&self,
ancestor: &Ancestor,
format: NumberFormat,
) -> Result<Arc<NodeTree<Flm>>, FormatError>
pub fn number_of_in( &self, ancestor: &Ancestor, format: NumberFormat, ) -> Result<Arc<NodeTree<Flm>>, FormatError>
Sourcepub fn literal(&self, text: &str) -> Result<Arc<NodeTree<Flm>>, FormatError>
pub fn literal(&self, text: &str) -> Result<Arc<NodeTree<Flm>>, FormatError>
Returns text as a small tree of content, built as the characters of
a number are: one text node attributed to the counter style’s source.
§Errors
FormatError when the content could not be built.
Sourcepub fn parts(&self, value: &NumberedValue<'_>) -> Result<Vec<Part>, FormatError>
pub fn parts(&self, value: &NumberedValue<'_>) -> Result<Vec<Part>, FormatError>
Returns the parts written before value’s own number: what its
within-joiner writes of the counters it is
numbered within.
The within-joiner runs the first time this method is called for a list of ancestors, and its result is kept for the rest of the call: a writer that never calls it never runs the within-joiner, and one that calls it for two values that share one list of ancestors runs it once. A value numbered within nothing has no part.
§Errors
FormatError::UnknownAncestor when the within-joiner refers to a
counter that is not in the chain, and a failure to build the content.
Sourcepub fn default_one(
&self,
value: &NumberedValue<'a>,
options: &FormatOptions,
out: &mut NumberOut<'a>,
) -> Result<(), FormatError>
pub fn default_one( &self, value: &NumberedValue<'a>, options: &FormatOptions, out: &mut NumberOut<'a>, ) -> Result<(), FormatError>
Sourcepub fn default_many(
&self,
values: &[NumberedValue<'a>],
options: &FormatOptions,
out: &mut NumberOut<'a>,
) -> Result<(), FormatError>
pub fn default_many( &self, values: &[NumberedValue<'a>], options: &FormatOptions, out: &mut NumberOut<'a>, ) -> Result<(), FormatError>
Writes values into out as the default writer would: grouped by the
counters they are numbered within, sorted, collapsed into ranges and
joined.
§Errors
The same as format_many.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !Freeze for WriteCx<'a>
impl<'a> !RefUnwindSafe for WriteCx<'a>
impl<'a> !Sync for WriteCx<'a>
impl<'a> !UnwindSafe for WriteCx<'a>
impl<'a> Forget for WriteCx<'a>
impl<'a> Move for WriteCx<'a>
impl<'a> Send for WriteCx<'a>
impl<'a> Unpin for WriteCx<'a>
impl<'a> UnsafeUnpin for WriteCx<'a>where
&'a CounterStyle: UnsafeUnpin,
*const LeafNode<(usize, usize, usize), Arc<Vec<Part>>> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<((usize, usize, usize), Arc<Vec<Part>>)>>: UnsafeUnpin,
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> 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