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 PatternItem
s 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 PatternItem
s.
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§
Trait Implementations§
source§impl<'data> BakeSize for Pattern<'data>
impl<'data> BakeSize for Pattern<'data>
source§fn borrows_size(&self) -> usize
fn borrows_size(&self) -> usize
Returns the size
source§impl<'de, 'data> Deserialize<'de> for Pattern<'data>where
'de: 'data,
impl<'de, 'data> Deserialize<'de> for Pattern<'data>where
'de: 'data,
source§fn deserialize<D>(
deserializer: D,
) -> Result<Pattern<'data>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Pattern<'data>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for Pattern<'_>
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§impl<'data> EncodeAsVarULE<PatternULE> for &Pattern<'data>
impl<'data> EncodeAsVarULE<PatternULE> for &Pattern<'data>
source§fn encode_var_ule_as_slices<R>(&self, cb: impl FnOnce(&[&[u8]]) -> R) -> R
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 moresource§fn encode_var_ule_len(&self) -> usize
fn encode_var_ule_len(&self) -> usize
Return the length, in bytes, of the corresponding
VarULE
typesource§fn encode_var_ule_write(&self, dst: &mut [u8])
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>
impl<'data> EncodeAsVarULE<PatternULE> for Pattern<'data>
source§fn encode_var_ule_as_slices<R>(&self, cb: impl FnOnce(&[&[u8]]) -> R) -> R
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 moresource§fn encode_var_ule_len(&self) -> usize
fn encode_var_ule_len(&self) -> usize
Return the length, in bytes, of the corresponding
VarULE
typesource§fn encode_var_ule_write(&self, dst: &mut [u8])
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> From<&'data PatternULE> for Pattern<'data>
impl<'data> From<&'data PatternULE> for Pattern<'data>
source§fn from(other: &'data PatternULE) -> Pattern<'data>
fn from(other: &'data PatternULE) -> Pattern<'data>
Converts to this type from the input type.
source§impl<'data> From<Pattern<'data>> for PatternPlurals<'data>
impl<'data> From<Pattern<'data>> for PatternPlurals<'data>
source§fn from(pattern: Pattern<'data>) -> PatternPlurals<'data>
fn from(pattern: Pattern<'data>) -> PatternPlurals<'data>
Converts to this type from the input type.
source§impl FromIterator<PatternItem> for Pattern<'_>
impl FromIterator<PatternItem> for Pattern<'_>
source§fn from_iter<T>(iter: T) -> Pattern<'_>where
T: IntoIterator<Item = PatternItem>,
fn from_iter<T>(iter: T) -> Pattern<'_>where
T: IntoIterator<Item = PatternItem>,
Creates a value from an iterator. Read more
source§impl Serialize for Pattern<'_>
impl Serialize for Pattern<'_>
source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
source§impl Writeable for Pattern<'_>
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>(&self, formatter: &mut W) -> Result<(), Error>
fn write_to<W>(&self, formatter: &mut W) -> Result<(), Error>
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,
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
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§impl<'a> Yokeable<'a> for Pattern<'static>
impl<'a> Yokeable<'a> for Pattern<'static>
source§type Output = Pattern<'a>
type Output = Pattern<'a>
This type MUST be
Self
with the 'static
replaced with 'a
, i.e. Self<'a>
source§impl<'data> ZeroFrom<'data, PatternULE> for Pattern<'data>
impl<'data> ZeroFrom<'data, PatternULE> for Pattern<'data>
source§fn zero_from(other: &'data PatternULE) -> Pattern<'data>
fn zero_from(other: &'data PatternULE) -> Pattern<'data>
Clone the other
C
into a struct that may retain references into C
.impl<'data> Eq for Pattern<'data>
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> 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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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>
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 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>
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