pub struct Key(/* private fields */);Expand description
Implementations§
Source§impl Key
impl Key
Sourcepub const fn try_from_str(s: &str) -> Result<Key, ParseError>
pub const fn try_from_str(s: &str) -> Result<Key, ParseError>
Sourcepub const fn try_from_utf8(code_units: &[u8]) -> Result<Key, ParseError>
pub const fn try_from_utf8(code_units: &[u8]) -> Result<Key, ParseError>
Sourcepub const fn try_from_raw(raw: [u8; 2]) -> Result<Key, ParseError>
pub const fn try_from_raw(raw: [u8; 2]) -> Result<Key, ParseError>
Safely creates a Key from its raw format
as returned by Self::into_raw. Unlike Self::try_from_utf8,
this constructor only takes normalized values.
Sourcepub const unsafe fn from_raw_unchecked(v: [u8; 2]) -> Key
pub const unsafe fn from_raw_unchecked(v: [u8; 2]) -> Key
Unsafely creates a Key from its raw format
as returned by Self::into_raw. Unlike Self::try_from_utf8,
this constructor only takes normalized values.
§Safety
This function is safe iff Self::try_from_raw returns an Ok. This is the case
for inputs that are correctly normalized.
Sourcepub const fn into_raw(self) -> [u8; 2]
pub const fn into_raw(self) -> [u8; 2]
Deconstructs into a raw format to be consumed by
from_raw_unchecked or
try_from_raw.
Sourcepub fn strict_cmp(self, other: &[u8]) -> Ordering
pub fn strict_cmp(self, other: &[u8]) -> Ordering
Compare with BCP-47 bytes.
The return value is equivalent to what would happen if you first converted
self to a BCP-47 string and then performed a byte comparison.
This function is case-sensitive and results in a total order, so it is appropriate for
binary search. The only argument producing Ordering::Equal
is self.as_str().as_bytes().
Sourcepub fn normalizing_eq(self, other: &str) -> bool
pub fn normalizing_eq(self, other: &str) -> bool
Compare with a potentially unnormalized BCP-47 string.
The return value is equivalent to what would happen if you first parsed the BCP-47 string and then performed a structural comparison.
Trait Implementations§
Source§impl Bake for Key
Available on crate feature databake only.
impl Bake for Key
databake only.Source§fn bake(&self, env: &CrateEnv) -> TokenStream
fn bake(&self, env: &CrateEnv) -> TokenStream
Source§impl BakeSize for Key
Available on crate feature databake only.
impl BakeSize for Key
databake only.Source§fn borrows_size(&self) -> usize
fn borrows_size(&self) -> usize
impl Copy for Key
Source§impl<'de> Deserialize<'de> for Key
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Key
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<Key, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Key, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for Key
This trait is implemented for compatibility with fmt!.
To create a string, [Writeable::write_to_string] is usually more efficient.
impl Display for Key
This trait is implemented for compatibility with fmt!.
To create a string, [Writeable::write_to_string] is usually more efficient.
impl Eq for Key
Source§impl NicheBytes<2> for Key
Available on crate feature zerovec only.
impl NicheBytes<2> for Key
zerovec only.const NICHE_BIT_PATTERN: [u8; 2] = tinystr::TinyAsciiStr<2>::NICHE_BIT_PATTERN
Source§impl Ord for Key
impl Ord for Key
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Key
impl PartialOrd for Key
Source§impl Serialize for Key
Available on crate feature serde only.
impl Serialize for Key
serde only.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,
impl StructuralPartialEq for Key
Source§impl ULE for Key
Available on crate feature zerovec only.
impl ULE for Key
zerovec only.Source§fn validate_bytes(bytes: &[u8]) -> Result<(), UleError>
fn validate_bytes(bytes: &[u8]) -> Result<(), UleError>
&[u8]. Read moreSource§unsafe fn slice_from_bytes_unchecked(bytes: &[u8]) -> &[Self]
unsafe fn slice_from_bytes_unchecked(bytes: &[u8]) -> &[Self]
&[u8], and return it as &[Self] with the same lifetime, assuming
that this byte slice has previously been run through Self::parse_bytes_to_slice() with
success. Read moreSource§impl Writeable for Key
impl Writeable for Key
Source§fn write_to<W>(&self, sink: &mut W) -> Result<(), Error>
fn write_to<W>(&self, sink: &mut W) -> Result<(), Error>
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,
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
Source§fn writeable_borrow(&self) -> Option<&str>
fn writeable_borrow(&self) -> Option<&str>
Auto Trait Implementations§
impl Freeze for Key
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnsafeUnpin for Key
impl UnwindSafe for Key
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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