Struct icu_datetime::provider::pattern::runtime::Pattern

source ·
pub struct Pattern<'data> {
    pub items: ZeroVec<'data, PatternItem>,
    pub metadata: PatternMetadata,
}
Expand description

A raw, low-level pattern for datetime formatting.

It consists of an owned-or-borrowed list of PatternItems corresponding to either fields or literal characters.

🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways, including in SemVer minor releases. While the serde representation of data structs is guaranteed to be stable, their Rust representation might not be. Use with caution.

Fields§

§items: ZeroVec<'data, PatternItem>

The list of PatternItems.

§metadata: PatternMetadata

Pre-computed metadata about the pattern.

This field should contain the smallest time unit from the items vec. If it doesn’t, unexpected results for day periods may be encountered.

Implementations§

source§

impl Pattern<'_>

source

pub fn to_string(&self) -> String

Converts the given value to a String.

Under the hood, this uses an efficient [Writeable] implementation. However, in order to avoid allocating a string, it is more efficient to use [Writeable] directly.

source§

impl Pattern<'_>

source

pub fn as_ref(&self) -> Pattern<'_>

Borrows a Pattern from another Pattern.

Trait Implementations§

source§

impl<'data> Bake for Pattern<'data>

source§

fn bake(&self, env: &CrateEnv) -> TokenStream

Returns a TokenStream that would evaluate to self. Read more
source§

impl<'data> BakeSize for Pattern<'data>

source§

fn borrows_size(&self) -> usize

Returns the size
source§

impl<'data> Clone for Pattern<'data>

source§

fn clone(&self) -> Pattern<'data>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'data> Debug for Pattern<'data>

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Pattern<'_>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de: 'data, 'data> Deserialize<'de> for Pattern<'data>

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Pattern<'_>

This trait is implemented for compatibility with fmt!. To create a string, [Writeable::write_to_string] is usually more efficient.

source§

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

Formats the value using the given formatter. Read more
source§

impl<'data> EncodeAsVarULE<PatternULE> for &Pattern<'data>

source§

fn encode_var_ule_as_slices<R>(&self, cb: impl FnOnce(&[&[u8]]) -> R) -> R

Calls cb with a piecewise list of byte slices that when concatenated produce the memory pattern of the corresponding instance of T. Read more
source§

fn encode_var_ule_len(&self) -> usize

Return the length, in bytes, of the corresponding [VarULE] type
source§

fn encode_var_ule_write(&self, dst: &mut [u8])

Write the corresponding [VarULE] type to the dst buffer. dst should be the size of [Self::encode_var_ule_len()]
source§

impl<'data> EncodeAsVarULE<PatternULE> for Pattern<'data>

source§

fn encode_var_ule_as_slices<R>(&self, cb: impl FnOnce(&[&[u8]]) -> R) -> R

Calls cb with a piecewise list of byte slices that when concatenated produce the memory pattern of the corresponding instance of T. Read more
source§

fn encode_var_ule_len(&self) -> usize

Return the length, in bytes, of the corresponding [VarULE] type
source§

fn encode_var_ule_write(&self, dst: &mut [u8])

Write the corresponding [VarULE] type to the dst buffer. dst should be the size of [Self::encode_var_ule_len()]
source§

impl From<&Pattern<'_>> for Bag

source§

fn from(pattern: &Pattern<'_>) -> Self

Converts to this type from the input type.
source§

impl From<&Pattern<'_>> for Pattern

source§

fn from(input: &Pattern<'_>) -> Self

Converts to this type from the input type.
source§

impl From<&Pattern> for Pattern<'_>

source§

fn from(input: &Pattern) -> Self

Converts to this type from the input type.
source§

impl<'data> From<&'data PatternULE> for Pattern<'data>

source§

fn from(other: &'data PatternULE) -> Self

Converts to this type from the input type.
source§

impl<'data> From<Pattern<'data>> for PatternPlurals<'data>

source§

fn from(pattern: Pattern<'data>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<PatternItem>> for Pattern<'_>

source§

fn from(items: Vec<PatternItem>) -> Self

Converts to this type from the input type.
source§

impl FromIterator<PatternItem> for Pattern<'_>

source§

fn from_iter<T: IntoIterator<Item = PatternItem>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl FromStr for Pattern<'_>

source§

type Err = PatternError

The associated error which can be returned from parsing.
source§

fn from_str(input: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl<'data> PartialEq for Pattern<'data>

source§

fn eq(&self, other: &Pattern<'data>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Pattern<'_>

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Writeable for Pattern<'_>

This trait is implemented in order to provide the machinery to convert a Pattern to a UTS 35 pattern string.

source§

fn write_to<W: Write + ?Sized>(&self, formatter: &mut W) -> Result

Writes a string to the given sink. Errors from the sink are bubbled up. The default implementation delegates to write_to_parts, and discards any Part annotations.
§

fn write_to_parts<S>(&self, sink: &mut S) -> Result<(), Error>
where S: PartsWrite + ?Sized,

Write bytes and Part annotations to the given sink. Errors from the sink are bubbled up. The default implementation delegates to write_to, and doesn’t produce any Part annotations.
§

fn writeable_length_hint(&self) -> LengthHint

Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more
§

fn write_to_string(&self) -> Cow<'_, str>

Creates a new String with the data from this Writeable. Like ToString, but smaller and faster. Read more
source§

impl<'a> Yokeable<'a> for Pattern<'static>

source§

type Output = Pattern<'a>

This type MUST be Self with the 'static replaced with 'a, i.e. Self<'a>
source§

fn transform(&'a self) -> &'a Self::Output

This method must cast self between &'a Self<'static> and &'a Self<'a>. Read more
source§

fn transform_owned(self) -> Self::Output

This method must cast self between Self<'static> and Self<'a>. Read more
source§

unsafe fn make(this: Self::Output) -> Self

This method can be used to cast away Self<'a>’s lifetime. Read more
source§

fn transform_mut<F>(&'a mut self, f: F)
where F: 'static + for<'b> FnOnce(&'b mut Self::Output),

This method must cast self between &'a mut Self<'static> and &'a mut Self<'a>, and pass it to f. Read more
source§

impl<'data> ZeroFrom<'data, PatternULE> for Pattern<'data>

source§

fn zero_from(other: &'data PatternULE) -> Self

Clone the other C into a struct that may retain references into C.
source§

impl<'zf, 'zf_inner> ZeroFrom<'zf, Pattern<'zf_inner>> for Pattern<'zf>

source§

fn zero_from(this: &'zf Pattern<'zf_inner>) -> Self

Clone the other C into a struct that may retain references into C.
source§

impl<'data> Eq for Pattern<'data>

source§

impl<'data> StructuralPartialEq for Pattern<'data>

Auto Trait Implementations§

§

impl<'data> Freeze for Pattern<'data>

§

impl<'data> RefUnwindSafe for Pattern<'data>

§

impl<'data> Send for Pattern<'data>

§

impl<'data> Sync for Pattern<'data>

§

impl<'data> Unpin for Pattern<'data>

§

impl<'data> UnwindSafe for Pattern<'data>

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> 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<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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<T> Serialize for T
where T: Serialize + ?Sized,

source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,