Implement Display for r0::keys::AlgorithmAndDeviceId
This commit is contained in:
parent
62bf717e62
commit
519ab3ff0a
@ -5,6 +5,10 @@ Breaking changes:
|
||||
* The `event_id` in the response for the message and state sending endpoints is now required
|
||||
* r0.6.0 doesn't say they are required, but this has been fixed for the next version of the spec
|
||||
|
||||
Improvements:
|
||||
|
||||
* `r0::keys::AlgorithmAndDeviceId` now implements `Display`
|
||||
|
||||
# 0.8.0
|
||||
|
||||
Breaking changes:
|
||||
|
@ -3,7 +3,7 @@
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
convert::TryFrom,
|
||||
fmt::{Debug, Display, Error as FmtError, Formatter},
|
||||
fmt::{self, Debug, Display, Formatter},
|
||||
};
|
||||
|
||||
use ruma_events::Algorithm;
|
||||
@ -35,7 +35,7 @@ pub enum KeyAlgorithm {
|
||||
}
|
||||
|
||||
impl Display for KeyAlgorithm {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
let algorithm_str = match *self {
|
||||
KeyAlgorithm::Ed25519 => "ed25519",
|
||||
KeyAlgorithm::Curve25519 => "curve25519",
|
||||
@ -62,13 +62,18 @@ impl TryFrom<&'_ str> for KeyAlgorithm {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct AlgorithmAndDeviceId(pub KeyAlgorithm, pub DeviceId);
|
||||
|
||||
impl Display for AlgorithmAndDeviceId {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}:{}", self.0, self.1)
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for AlgorithmAndDeviceId {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let s = format!("{}:{}", self.0, self.1);
|
||||
serializer.serialize_str(&s)
|
||||
serializer.serialize_str(&self.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user