pub struct KeyId<A, K>(/* private fields */)
where
A: KeyAlgorithm,
K: KeyName + ?Sized;
Expand description
A key algorithm and key name delimited by a colon.
Examples of the use of this struct are DeviceKeyId
, which identifies a Ed25519 or Curve25519
device key, and
CrossSigningKeyId
, which identifies a user’s
cross signing key.
This format of identifier is often used in the signatures
field of
signed JSON
where it is referred to as a “signing key identifier”.
This struct is rarely used directly - instead you should expect to use one of the type aliases
that rely on it like CrossSigningKeyId
or DeviceSigningKeyId
.
§Examples
To parse a colon-separated identifier:
use ruma_common::DeviceKeyId;
let k = DeviceKeyId::parse("ed25519:1").unwrap();
assert_eq!(k.algorithm().as_str(), "ed25519");
assert_eq!(k.key_name(), "1");
To construct a colon-separated identifier from its parts:
use ruma_common::{DeviceKeyAlgorithm, DeviceKeyId};
let k = DeviceKeyId::from_parts(DeviceKeyAlgorithm::Curve25519, "MYDEVICE".into());
assert_eq!(k.as_str(), "curve25519:MYDEVICE");
Implementations§
Source§impl<A, K> KeyId<A, K>
impl<A, K> KeyId<A, K>
Sourcepub fn parse(s: impl AsRef<str>) -> Result<OwnedKeyId<A, K>, Error>
pub fn parse(s: impl AsRef<str>) -> Result<OwnedKeyId<A, K>, Error>
Try parsing a &str
into an OwnedKeyId
.
The same can also be done using FromStr
, TryFrom
or TryInto
.
This function is simply more constrained and thus useful in generic contexts.
Sourcepub fn parse_box(
s: impl AsRef<str> + Into<Box<str>>,
) -> Result<Box<KeyId<A, K>>, Error>
pub fn parse_box( s: impl AsRef<str> + Into<Box<str>>, ) -> Result<Box<KeyId<A, K>>, Error>
Try parsing a &str
into a Box<KeyId>
.
The same can also be done using FromStr
, TryFrom
or TryInto
.
This function is simply more constrained and thus useful in generic contexts.
Source§impl<A, K> KeyId<A, K>
impl<A, K> KeyId<A, K>
Sourcepub fn from_parts(algorithm: A, key_name: &K) -> OwnedKeyId<A, K>
pub fn from_parts(algorithm: A, key_name: &K) -> OwnedKeyId<A, K>
Creates a new KeyId
from an algorithm and key name.
Trait Implementations§
Source§impl<A, K> AsRef<KeyId<A, K>> for OwnedKeyId<A, K>
impl<A, K> AsRef<KeyId<A, K>> for OwnedKeyId<A, K>
Source§impl<A, K> Borrow<KeyId<A, K>> for OwnedKeyId<A, K>
impl<A, K> Borrow<KeyId<A, K>> for OwnedKeyId<A, K>
Source§impl<'de, A, K> Deserialize<'de> for Box<KeyId<A, K>>
impl<'de, A, K> Deserialize<'de> for Box<KeyId<A, K>>
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Box<KeyId<A, K>>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Box<KeyId<A, K>>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<A, K> From<&KeyId<A, K>> for OwnedKeyId<A, K>
impl<A, K> From<&KeyId<A, K>> for OwnedKeyId<A, K>
Source§fn from(id: &KeyId<A, K>) -> OwnedKeyId<A, K>
fn from(id: &KeyId<A, K>) -> OwnedKeyId<A, K>
Source§impl<A, K> PartialEq<&KeyId<A, K>> for OwnedKeyId<A, K>
impl<A, K> PartialEq<&KeyId<A, K>> for OwnedKeyId<A, K>
Source§impl<A, K> PartialEq<KeyId<A, K>> for OwnedKeyId<A, K>
impl<A, K> PartialEq<KeyId<A, K>> for OwnedKeyId<A, K>
Source§impl<A, K> PartialEq<OwnedKeyId<A, K>> for &KeyId<A, K>
impl<A, K> PartialEq<OwnedKeyId<A, K>> for &KeyId<A, K>
Source§impl<A, K> PartialEq<OwnedKeyId<A, K>> for KeyId<A, K>
impl<A, K> PartialEq<OwnedKeyId<A, K>> for KeyId<A, K>
Source§impl<A, K> PartialOrd for KeyId<A, K>
impl<A, K> PartialOrd for KeyId<A, K>
Source§impl<A, K> Serialize for KeyId<A, K>
impl<A, K> Serialize for KeyId<A, K>
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,
Source§impl<A, K> ToOwned for KeyId<A, K>
impl<A, K> ToOwned for KeyId<A, K>
Source§type Owned = OwnedKeyId<A, K>
type Owned = OwnedKeyId<A, K>
Source§fn to_owned(&self) -> <KeyId<A, K> as ToOwned>::Owned
fn to_owned(&self) -> <KeyId<A, K> as ToOwned>::Owned
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
impl<A, K> Eq for KeyId<A, K>
Auto Trait Implementations§
impl<A, K> Freeze for KeyId<A, K>where
K: ?Sized,
impl<A, K> RefUnwindSafe for KeyId<A, K>
impl<A, K> Send for KeyId<A, K>
impl<A, K> !Sized for KeyId<A, K>
impl<A, K> Sync for KeyId<A, K>
impl<A, K> Unpin for KeyId<A, K>
impl<A, K> UnwindSafe for KeyId<A, K>
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.