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, 'data> Deserialize<'de> for Pattern<'data>
impl<'de: 'data, 'data> Deserialize<'de> for Pattern<'data>
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
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<'_>
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) -> Self
fn from(other: &'data PatternULE) -> Self
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§impl From<Vec<PatternItem>> for Pattern<'_>
impl From<Vec<PatternItem>> for Pattern<'_>
source§fn from(items: Vec<PatternItem>) -> Self
fn from(items: Vec<PatternItem>) -> Self
Converts to this type from the input type.
source§impl FromIterator<PatternItem> for Pattern<'_>
impl FromIterator<PatternItem> for Pattern<'_>
source§fn from_iter<T: IntoIterator<Item = PatternItem>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = PatternItem>>(iter: T) -> Self
Creates a value from an iterator. 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: Write + ?Sized>(&self, formatter: &mut W) -> Result
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,
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
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>
fn write_to_string(&self) -> Cow<'_, str>
Creates a new
String
with the data from this Writeable
. Like ToString
,
but smaller and faster. Read moresource§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§fn transform_owned(self) -> Self::Output
fn transform_owned(self) -> Self::Output
source§unsafe fn make(this: Self::Output) -> Self
unsafe fn make(this: Self::Output) -> Self
This method can be used to cast away
Self<'a>
’s lifetime. Read moresource§fn transform_mut<F>(&'a mut self, f: F)where
F: 'static + for<'b> FnOnce(&'b mut Self::Output),
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 moresource§impl<'data> ZeroFrom<'data, PatternULE> for Pattern<'data>
impl<'data> ZeroFrom<'data, PatternULE> for Pattern<'data>
source§fn zero_from(other: &'data PatternULE) -> Self
fn zero_from(other: &'data PatternULE) -> Self
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