Struct 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> 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 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 From<DateTimePattern> for Pattern<'_>

Sourceยง

fn from(value: DateTimePattern) -> Self

Converts to this type from the input type.
Sourceยง

impl<'a> From<Pattern<'a>> for DateTimePattern

Sourceยง

fn from(pattern: Pattern<'a>) -> 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 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.
Sourceยง

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.
Sourceยง

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

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, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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ยง

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

Sourceยง

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