Skip to main content

WriteCx

Struct WriteCx 

Source
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>

Source

pub fn style(&self) -> &'a CounterStyle

Returns the counter style in which every value of this call is written.

Source

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.

Source

pub fn open(&self) -> &'a Arc<NodeTree<Flm>> ⓘ

Returns the counter style’s opening delimiter, the text written before a number.

Source

pub fn close(&self) -> &'a Arc<NodeTree<Flm>> ⓘ

Returns the counter style’s closing delimiter, the text written after a number.

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.

Source

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.

Source

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.

Source

pub fn join_text(&self, which: JoinText) -> &'a Arc<NodeTree<Flm>> ⓘ

Returns the counter style’s join text which.

Source

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.

Source

pub fn number_in( &self, value: &CounterValue, format: NumberFormat, ) -> Result<Arc<NodeTree<Flm>>, FormatError>

Returns value written in format instead of with the counter style’s own number template, its sub-numbers in that format too.

§Errors

The same as number.

Source

pub fn number_of( &self, ancestor: &Ancestor, ) -> Result<Arc<NodeTree<Flm>>, FormatError>

Returns ancestor’s own number, written in the ancestor’s own counter style: the number alone, with no word, no delimiters and nothing of its own ancestors.

§Errors

The same as number, for the ancestor’s counter style.

Source

pub fn number_of_in( &self, ancestor: &Ancestor, format: NumberFormat, ) -> Result<Arc<NodeTree<Flm>>, FormatError>

Returns ancestor’s own number written in format instead of the format of its own counter style.

§Errors

The same as number, for the ancestor’s counter style.

Source

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.

Source

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.

Source

pub fn default_one( &self, value: &NumberedValue<'a>, options: &FormatOptions, out: &mut NumberOut<'a>, ) -> Result<(), FormatError>

Writes value into out as the default writer would: the word, the delimiters, the parts and the number.

A writer calls it to add to the default text instead of replacing it: Eq.~(5), followed by in Section~V of its own.

§Errors

The same as format.

Source

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§

Source§

impl Debug for WriteCx<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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>
where &'a CounterStyle: Unpin, *const LeafNode<(usize, usize, usize), Arc<Vec<Part>>> is !null: Unpin, Box<((usize, usize, usize), Arc<Vec<Part>>)>: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.