events: Drop M prefix from enum variants

This commit is contained in:
Jonas Platte 2021-06-14 13:29:15 +02:00
parent 28de60a90a
commit f179a5c771
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
5 changed files with 19 additions and 17 deletions

View File

@ -2,7 +2,9 @@
Breaking changes: Breaking changes:
* Fix the name of the qr code scan verification method (`MQrScanShowV1` => `MQrCodeScanV1`) * Rename `key::verification::AcceptMethod::{MSasV1 => SasV1}`
* As above, drop `M` prefix from `key::verification::VerificationMethod` variants
* Additionally, fix the name of the QR code one (`QrScanShowV1` to `QrCodeScanV1`)
# 0.22.2 # 0.22.2

View File

@ -129,22 +129,22 @@ impl TryFrom<RelatesToJsonRepr> for Relation {
pub enum VerificationMethod { pub enum VerificationMethod {
/// The *m.sas.v1* verification method. /// The *m.sas.v1* verification method.
#[ruma_enum(rename = "m.sas.v1")] #[ruma_enum(rename = "m.sas.v1")]
MSasV1, SasV1,
/// The *m.qr_code.scan.v1* verification method. /// The *m.qr_code.scan.v1* verification method.
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
#[ruma_enum(rename = "m.qr_code.scan.v1")] #[ruma_enum(rename = "m.qr_code.scan.v1")]
MQrCodeScanV1, QrCodeScanV1,
/// The *m.qr_code.show.v1* verification method. /// The *m.qr_code.show.v1* verification method.
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
#[ruma_enum(rename = "m.qr_code.show.v1")] #[ruma_enum(rename = "m.qr_code.show.v1")]
MQrCodeShowV1, QrCodeShowV1,
/// The *m.reciprocate.v1* verification method. /// The *m.reciprocate.v1* verification method.
#[cfg(feature = "unstable-pre-spec")] #[cfg(feature = "unstable-pre-spec")]
#[ruma_enum(rename = "m.reciprocate.v1")] #[ruma_enum(rename = "m.reciprocate.v1")]
MReciprocateV1, ReciprocateV1,
#[doc(hidden)] #[doc(hidden)]
_Custom(String), _Custom(String),

View File

@ -74,7 +74,7 @@ impl AcceptEventContent {
#[serde(untagged)] #[serde(untagged)]
pub enum AcceptMethod { pub enum AcceptMethod {
/// The *m.sas.v1* verification method. /// The *m.sas.v1* verification method.
MSasV1(SasV1Content), SasV1(SasV1Content),
/// Any unknown accept method. /// Any unknown accept method.
Custom(CustomContent), Custom(CustomContent),
@ -186,7 +186,7 @@ mod tests {
fn serialization() { fn serialization() {
let key_verification_accept_content = AcceptToDeviceEventContent { let key_verification_accept_content = AcceptToDeviceEventContent {
transaction_id: "456".into(), transaction_id: "456".into(),
method: AcceptMethod::MSasV1(SasV1Content { method: AcceptMethod::SasV1(SasV1Content {
hash: HashAlgorithm::Sha256, hash: HashAlgorithm::Sha256,
key_agreement_protocol: KeyAgreementProtocol::Curve25519, key_agreement_protocol: KeyAgreementProtocol::Curve25519,
message_authentication_code: MessageAuthenticationCode::HkdfHmacSha256, message_authentication_code: MessageAuthenticationCode::HkdfHmacSha256,
@ -251,7 +251,7 @@ mod tests {
let key_verification_accept_content = AcceptEventContent { let key_verification_accept_content = AcceptEventContent {
relation: Relation { event_id: event_id.clone() }, relation: Relation { event_id: event_id.clone() },
method: AcceptMethod::MSasV1(SasV1Content { method: AcceptMethod::SasV1(SasV1Content {
hash: HashAlgorithm::Sha256, hash: HashAlgorithm::Sha256,
key_agreement_protocol: KeyAgreementProtocol::Curve25519, key_agreement_protocol: KeyAgreementProtocol::Curve25519,
message_authentication_code: MessageAuthenticationCode::HkdfHmacSha256, message_authentication_code: MessageAuthenticationCode::HkdfHmacSha256,
@ -296,7 +296,7 @@ mod tests {
.unwrap(), .unwrap(),
AcceptToDeviceEventContent { AcceptToDeviceEventContent {
transaction_id, transaction_id,
method: AcceptMethod::MSasV1(SasV1Content { method: AcceptMethod::SasV1(SasV1Content {
commitment, commitment,
hash, hash,
key_agreement_protocol, key_agreement_protocol,
@ -336,7 +336,7 @@ mod tests {
sender, sender,
content: AcceptToDeviceEventContent { content: AcceptToDeviceEventContent {
transaction_id, transaction_id,
method: AcceptMethod::MSasV1(SasV1Content { method: AcceptMethod::SasV1(SasV1Content {
commitment, commitment,
hash, hash,
key_agreement_protocol, key_agreement_protocol,
@ -415,7 +415,7 @@ mod tests {
relation: Relation { relation: Relation {
event_id event_id
}, },
method: AcceptMethod::MSasV1(SasV1Content { method: AcceptMethod::SasV1(SasV1Content {
commitment, commitment,
hash, hash,
key_agreement_protocol, key_agreement_protocol,

View File

@ -95,7 +95,7 @@ mod tests {
let content = ReadyEventContent { let content = ReadyEventContent {
from_device: device.clone(), from_device: device.clone(),
relation: Relation { event_id }, relation: Relation { event_id },
methods: vec![VerificationMethod::MSasV1], methods: vec![VerificationMethod::SasV1],
}; };
assert_eq!(to_json_value(&content).unwrap(), json_data); assert_eq!(to_json_value(&content).unwrap(), json_data);
@ -109,7 +109,7 @@ mod tests {
let content = ReadyToDeviceEventContent { let content = ReadyToDeviceEventContent {
from_device: device, from_device: device,
transaction_id: "456".to_owned(), transaction_id: "456".to_owned(),
methods: vec![VerificationMethod::MSasV1], methods: vec![VerificationMethod::SasV1],
}; };
assert_eq!(to_json_value(&content).unwrap(), json_data); assert_eq!(to_json_value(&content).unwrap(), json_data);
@ -141,7 +141,7 @@ mod tests {
}, },
methods, methods,
} if from_device == device } if from_device == device
&& methods == vec![VerificationMethod::MSasV1] && methods == vec![VerificationMethod::SasV1]
&& event_id == id && event_id == id
); );
@ -161,7 +161,7 @@ mod tests {
transaction_id, transaction_id,
methods, methods,
} if from_device == device } if from_device == device
&& methods == vec![VerificationMethod::MSasV1] && methods == vec![VerificationMethod::SasV1]
&& transaction_id == "456" && transaction_id == "456"
); );
} }

View File

@ -327,7 +327,7 @@ fn verification_request_deserialization() {
} if body == "@example:localhost is requesting to verify your key, ..." } if body == "@example:localhost is requesting to verify your key, ..."
&& to == user_id && to == user_id
&& from_device == device_id && from_device == device_id
&& methods.contains(&VerificationMethod::MSasV1) && methods.contains(&VerificationMethod::SasV1)
); );
} }
@ -339,7 +339,7 @@ fn verification_request_serialization() {
let body = "@example:localhost is requesting to verify your key, ...".to_owned(); let body = "@example:localhost is requesting to verify your key, ...".to_owned();
let methods = vec![ let methods = vec![
VerificationMethod::MSasV1, VerificationMethod::SasV1,
VerificationMethod::_Custom("m.qr_code.show.v1".to_owned()), VerificationMethod::_Custom("m.qr_code.show.v1".to_owned()),
VerificationMethod::_Custom("m.reciprocate.v1".to_owned()), VerificationMethod::_Custom("m.reciprocate.v1".to_owned()),
]; ];