EventResult::into --> EventResult::into_result

This commit is contained in:
Jimmy Cuadra 2019-08-05 16:32:14 -07:00
parent 30c1ef07dc
commit 4984868e21
2 changed files with 8 additions and 8 deletions

View File

@ -602,7 +602,7 @@ mod tests {
r#"{"from_device":"123","transaction_id":"456","method":"m.sas.v1","hashes":["sha256"],"key_agreement_protocols":["curve25519"],"message_authentication_codes":["hkdf-hmac-sha256"],"short_authentication_string":["decimal"]}"# r#"{"from_device":"123","transaction_id":"456","method":"m.sas.v1","hashes":["sha256"],"key_agreement_protocols":["curve25519"],"message_authentication_codes":["hkdf-hmac-sha256"],"short_authentication_string":["decimal"]}"#
) )
.unwrap() .unwrap()
.into() .into_result()
.unwrap(), .unwrap(),
key_verification_start_content key_verification_start_content
); );
@ -616,7 +616,7 @@ mod tests {
r#"{"content":{"from_device":"123","transaction_id":"456","method":"m.sas.v1","key_agreement_protocols":["curve25519"],"hashes":["sha256"],"message_authentication_codes":["hkdf-hmac-sha256"],"short_authentication_string":["decimal"]},"type":"m.key.verification.start"}"# r#"{"content":{"from_device":"123","transaction_id":"456","method":"m.sas.v1","key_agreement_protocols":["curve25519"],"hashes":["sha256"],"message_authentication_codes":["hkdf-hmac-sha256"],"short_authentication_string":["decimal"]},"type":"m.key.verification.start"}"#
) )
.unwrap() .unwrap()
.into() .into_result()
.unwrap(), .unwrap(),
key_verification_start key_verification_start
) )
@ -634,7 +634,7 @@ mod tests {
let error = let error =
serde_json::from_str::<EventResult<StartEventContent>>(r#"{"from_device":"123"}"#) serde_json::from_str::<EventResult<StartEventContent>>(r#"{"from_device":"123"}"#)
.unwrap() .unwrap()
.into() .into_result()
.unwrap_err(); .unwrap_err();
assert!(error.message().contains("missing field")); assert!(error.message().contains("missing field"));
@ -648,7 +648,7 @@ mod tests {
r#"{"from_device":"123","transaction_id":"456","method":"m.sas.v1","key_agreement_protocols":[],"hashes":["sha256"],"message_authentication_codes":["hkdf-hmac-sha256"],"short_authentication_string":["decimal"]}"# r#"{"from_device":"123","transaction_id":"456","method":"m.sas.v1","key_agreement_protocols":[],"hashes":["sha256"],"message_authentication_codes":["hkdf-hmac-sha256"],"short_authentication_string":["decimal"]}"#
) )
.unwrap() .unwrap()
.into() .into_result()
.unwrap_err(); .unwrap_err();
assert!(error.message().contains("key_agreement_protocols")); assert!(error.message().contains("key_agreement_protocols"));
@ -662,7 +662,7 @@ mod tests {
r#"{"from_device":"123","transaction_id":"456","method":"m.sas.v1","key_agreement_protocols":["curve25519"],"hashes":[],"message_authentication_codes":["hkdf-hmac-sha256"],"short_authentication_string":["decimal"]}"# r#"{"from_device":"123","transaction_id":"456","method":"m.sas.v1","key_agreement_protocols":["curve25519"],"hashes":[],"message_authentication_codes":["hkdf-hmac-sha256"],"short_authentication_string":["decimal"]}"#
) )
.unwrap() .unwrap()
.into() .into_result()
.unwrap_err(); .unwrap_err();
assert!(error.message().contains("hashes")); assert!(error.message().contains("hashes"));
@ -676,7 +676,7 @@ mod tests {
r#"{"from_device":"123","transaction_id":"456","method":"m.sas.v1","key_agreement_protocols":["curve25519"],"hashes":["sha256"],"message_authentication_codes":[],"short_authentication_string":["decimal"]}"# r#"{"from_device":"123","transaction_id":"456","method":"m.sas.v1","key_agreement_protocols":["curve25519"],"hashes":["sha256"],"message_authentication_codes":[],"short_authentication_string":["decimal"]}"#
) )
.unwrap() .unwrap()
.into() .into_result()
.unwrap_err(); .unwrap_err();
assert!(error.message().contains("message_authentication_codes")); assert!(error.message().contains("message_authentication_codes"));
@ -690,7 +690,7 @@ mod tests {
r#"{"from_device":"123","transaction_id":"456","method":"m.sas.v1","key_agreement_protocols":["curve25519"],"hashes":["sha256"],"message_authentication_codes":["hkdf-hmac-sha256"],"short_authentication_string":[]}"# r#"{"from_device":"123","transaction_id":"456","method":"m.sas.v1","key_agreement_protocols":["curve25519"],"hashes":["sha256"],"message_authentication_codes":["hkdf-hmac-sha256"],"short_authentication_string":[]}"#
) )
.unwrap() .unwrap()
.into() .into_result()
.unwrap_err(); .unwrap_err();
assert!(error.message().contains("short_authentication_string")); assert!(error.message().contains("short_authentication_string"));

View File

@ -255,7 +255,7 @@ pub enum EventResult<T> {
impl<T> EventResult<T> { impl<T> EventResult<T> {
/// Convert `EventResult<T>` into the equivalent `std::result::Result<T, InvalidEvent>`. /// Convert `EventResult<T>` into the equivalent `std::result::Result<T, InvalidEvent>`.
pub fn into(self) -> Result<T, InvalidEvent> { pub fn into_result(self) -> Result<T, InvalidEvent> {
match self { match self {
EventResult::Ok(t) => Ok(t), EventResult::Ok(t) => Ok(t),
EventResult::Err(invalid_event) => Err(invalid_event), EventResult::Err(invalid_event) => Err(invalid_event),