Struct DcChar
pub struct DcChar(pub u128);Expand description
A single Document Character (Dc) or Unicode codepoint, represented as a 128-bit integer.
Tuple Fields§
§0: u128Implementations§
§impl DcChar
impl DcChar
pub const REPLACEMENT: DcChar
pub const REPLACEMENT: DcChar
Unicode replacement character (U+FFFD).
pub const fn from_short(short_id: u32) -> DcChar
pub const fn from_short(short_id: u32) -> DcChar
Creates a DcChar from a short Document Character ID (u32).
Computes SHORT_DC_REGION_START + short_id.
pub fn to_short(self) -> Result<u32, Error>
pub fn to_short(self) -> Result<u32, Error>
Converts this DcChar into a short Document Character ID (u32).
§Errors
Returns an error if this character is not in the short Document
Character region (SHORT_DC_REGION_START..=SHORT_DC_REGION_END).
pub const fn from_format(fmt_id: u32) -> DcChar
pub const fn from_format(fmt_id: u32) -> DcChar
Creates a DcChar from a short Format ID (u32).
Computes FORMAT_REGION_START + fmt_id.
pub fn to_format(self) -> Result<u32, Error>
pub fn to_format(self) -> Result<u32, Error>
Converts this DcChar into a short Format ID (u32).
§Errors
Returns an error if this character is not in the Format region
(FORMAT_REGION_START..=FORMAT_REGION_END).
pub fn from_unicode(cp: u32) -> Result<DcChar, Error>
pub fn from_unicode(cp: u32) -> Result<DcChar, Error>
pub fn to_unicode(self) -> Result<u32, Error>
pub fn to_unicode(self) -> Result<u32, Error>
Converts this DcChar into a Unicode codepoint (u32).
§Errors
Returns an error if this character exceeds 0x10_FFFF.
pub fn as_char(self) -> Option<char>
pub fn as_char(self) -> Option<char>
Attempts to convert this DcChar into a standard Unicode char.
Returns Some(char) if this codepoint is a valid Unicode scalar value
(0..=0x10FFFF, excluding surrogate halves 0xD800..=0xDFFF).
pub const fn is_unicode(self) -> bool
pub const fn is_unicode(self) -> bool
Returns true if this codepoint is within the Unicode range
(0..=0x10FFFF), including surrogate code points.
pub const fn is_unicode_scalar(self) -> bool
pub const fn is_unicode_scalar(self) -> bool
Returns true if this codepoint is a valid Unicode scalar value
(excluding surrogate code points 0xD800..=0xDFFF).
pub const fn is_ascii(self) -> bool
pub const fn is_ascii(self) -> bool
Returns true if this codepoint is within the standard ASCII range
(0..=0x7F).
pub const fn is_short_dc(self) -> bool
pub const fn is_short_dc(self) -> bool
Returns true if this character is a short Document Character
(in range SHORT_DC_REGION_START..=SHORT_DC_REGION_END).
pub fn to_short_dc(self) -> Option<u32>
pub fn to_short_dc(self) -> Option<u32>
Converts this character to a short Document Character number if in range.
Trait Implementations§
Source§impl DcCharExt for DcChar
impl DcCharExt for DcChar
Source§fn is_type_token(self) -> bool
fn is_type_token(self) -> bool
Source§fn fills_role(self, role: DcRole) -> bool
fn fills_role(self, role: DcRole) -> bool
Source§fn fills_role_with(
self,
role: DcRole,
resolver: &dyn SyntaxRuleResolver,
) -> bool
fn fills_role_with( self, role: DcRole, resolver: &dyn SyntaxRuleResolver, ) -> bool
Source§fn to_short_vec(self) -> Vec<u32>
fn to_short_vec(self) -> Vec<u32>
Source§fn len_dctf(self) -> usize
fn len_dctf(self) -> usize
DcChar in
DcTF (.dctf, f641) format (1..=23 bytes).Source§fn len_utf_8e_128(self) -> usize
fn len_utf_8e_128(self) -> usize
DcChar in legacy
UTF-8e-128 (DcUtf, f89) format (1..=24 bytes).Source§fn encode_buf(self, buf: &mut [u8]) -> usize
fn encode_buf(self, buf: &mut [u8]) -> usize
DcChar in DcTF into the provided byte buffer (must be
at least 23 bytes) and returns the number of bytes written.Source§impl Extend<DcChar> for DcMstring
impl Extend<DcChar> for DcMstring
Source§fn extend<I: IntoIterator<Item = DcChar>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = DcChar>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<DcChar> for DcString
impl Extend<DcChar> for DcString
Source§fn extend<I: IntoIterator<Item = DcChar>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = DcChar>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl FromIterator<DcChar> for DcMstring
impl FromIterator<DcChar> for DcMstring
Source§impl FromIterator<DcChar> for DcString
impl FromIterator<DcChar> for DcString
§impl Ord for DcChar
impl Ord for DcChar
§impl PartialOrd for DcChar
impl PartialOrd for DcChar
impl Copy for DcChar
impl Eq for DcChar
impl StructuralPartialEq for DcChar
Auto Trait Implementations§
impl Freeze for DcChar
impl RefUnwindSafe for DcChar
impl Send for DcChar
impl Sync for DcChar
impl Unpin for DcChar
impl UnwindSafe for DcChar
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
fn exact_from(value: T) -> U
§impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
fn exact_into(self) -> U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);