pub struct KeyId<A: KeyAlgorithm, K: KeyName + ?Sized>(/* private fields */);
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: KeyAlgorithm, K: KeyName + ?Sized> KeyId<A, K>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> KeyId<A, K>
Sourcepub fn parse(s: impl AsRef<str>) -> Result<OwnedKeyId<A, K>, IdParseError>
pub fn parse(s: impl AsRef<str>) -> Result<OwnedKeyId<A, K>, IdParseError>
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<Self>, IdParseError>
pub fn parse_box( s: impl AsRef<str> + Into<Box<str>>, ) -> Result<Box<Self>, IdParseError>
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: KeyAlgorithm, K: KeyName + ?Sized> KeyId<A, K>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> 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: KeyAlgorithm, K: KeyName + ?Sized> AsRef<KeyId<A, K>> for OwnedKeyId<A, K>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> AsRef<KeyId<A, K>> for OwnedKeyId<A, K>
Source§impl<A: KeyAlgorithm, K: KeyName + ?Sized> Borrow<KeyId<A, K>> for OwnedKeyId<A, K>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> Borrow<KeyId<A, K>> for OwnedKeyId<A, K>
Source§impl<'de, A: KeyAlgorithm, K: KeyName + ?Sized> Deserialize<'de> for Box<KeyId<A, K>>
impl<'de, A: KeyAlgorithm, K: KeyName + ?Sized> Deserialize<'de> for Box<KeyId<A, K>>
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>,
Source§impl<A: KeyAlgorithm, K: KeyName + ?Sized> From<&KeyId<A, K>> for OwnedKeyId<A, K>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> 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: KeyAlgorithm, K: KeyName + ?Sized> From<OwnedKeyId<A, K>> for Box<KeyId<A, K>>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> From<OwnedKeyId<A, K>> for Box<KeyId<A, K>>
Source§impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialEq<&KeyId<A, K>> for OwnedKeyId<A, K>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialEq<&KeyId<A, K>> for OwnedKeyId<A, K>
Source§impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialEq<KeyId<A, K>> for OwnedKeyId<A, K>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialEq<KeyId<A, K>> for OwnedKeyId<A, K>
Source§impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialEq<OwnedKeyId<A, K>> for &KeyId<A, K>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialEq<OwnedKeyId<A, K>> for &KeyId<A, K>
Source§impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialEq<OwnedKeyId<A, K>> for Box<KeyId<A, K>>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialEq<OwnedKeyId<A, K>> for Box<KeyId<A, K>>
Source§impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialEq<OwnedKeyId<A, K>> for KeyId<A, K>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialEq<OwnedKeyId<A, K>> for KeyId<A, K>
Source§impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialOrd for KeyId<A, K>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> PartialOrd for KeyId<A, K>
Source§impl<A: KeyAlgorithm, K: KeyName + ?Sized> ToOwned for KeyId<A, K>
impl<A: KeyAlgorithm, K: KeyName + ?Sized> ToOwned for KeyId<A, K>
Source§type Owned = OwnedKeyId<A, K>
type Owned = OwnedKeyId<A, K>
Source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
1.63.0 · Source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
impl<A: KeyAlgorithm, K: KeyName + ?Sized> 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.