@@ -4,7 +4,7 @@ use std::net::Ipv4Addr;
44
55use nested_enum_utils:: common_fields;
66use num_enum:: { IntoPrimitive , TryFromPrimitive } ;
7- use snafu:: Snafu ;
7+ use snafu:: { Backtrace , Snafu } ;
88
99use super :: { MapProtocol , Opcode , Version } ;
1010
@@ -55,44 +55,41 @@ pub enum ResultCode {
5555/// Errors that can occur when decoding a [`Response`] from a server.
5656#[ common_fields( {
5757 backtrace: Option <Backtrace >,
58- #[ snafu( implicit) ]
59- span_trace: n0_snafu:: SpanTrace ,
6058} ) ]
6159#[ allow( missing_docs) ]
62- #[ derive( Debug , Snafu , PartialEq , Eq ) ]
60+ #[ derive( Debug , Snafu ) ]
6361#[ non_exhaustive]
64- #[ snafu( visibility( pub ( crate ) ) ) ]
6562pub enum Error {
6663 /// Request is too short or is otherwise malformed.
6764 #[ snafu( display( "Response is malformed" ) ) ]
68- Malformed ,
65+ Malformed { } ,
6966 /// The [`Response::RESPONSE_INDICATOR`] is not present.
7067 #[ snafu( display( "Packet does not appear to be a response" ) ) ]
71- NotAResponse ,
68+ NotAResponse { } ,
7269 /// The received opcode is not recognized.
7370 #[ snafu( display( "Invalid Opcode received" ) ) ]
74- InvalidOpcode ,
71+ InvalidOpcode { } ,
7572 /// The received version is not recognized.
7673 #[ snafu( display( "Invalid version received" ) ) ]
77- InvalidVersion ,
74+ InvalidVersion { } ,
7875 /// The received result code is not recognized.
7976 #[ snafu( display( "Invalid result code received" ) ) ]
80- InvalidResultCode ,
77+ InvalidResultCode { } ,
8178 /// Received an error code indicating the server does not support the sent version.
8279 #[ snafu( display( "Server does not support the version" ) ) ]
83- UnsupportedVersion ,
80+ UnsupportedVersion { } ,
8481 /// Received an error code indicating the operation is supported but not authorized.
8582 #[ snafu( display( "Operation is supported but not authorized" ) ) ]
86- NotAuthorizedOrRefused ,
83+ NotAuthorizedOrRefused { } ,
8784 /// Received an error code indicating the server experienced a network failure
8885 #[ snafu( display( "Server experienced a network failure" ) ) ]
89- NetworkFailure ,
86+ NetworkFailure { } ,
9087 /// Received an error code indicating the server cannot create more mappings at this time.
9188 #[ snafu( display( "Server is out of resources" ) ) ]
92- OutOfResources ,
89+ OutOfResources { } ,
9390 /// Received an error code indicating the Opcode is not supported by the server.
9491 #[ snafu( display( "Server does not support this opcode" ) ) ]
95- UnsupportedOpcode ,
92+ UnsupportedOpcode { } ,
9693}
9794
9895impl Response {
@@ -283,7 +280,7 @@ mod tests {
283280
284281 let response = Response :: random ( Opcode :: DetermineExternalAddress , & mut gen) ;
285282 let encoded = response. encode ( ) ;
286- assert_eq ! ( Ok ( response) , Response :: decode( & encoded) ) ;
283+ assert_eq ! ( response, Response :: decode( & encoded) . unwrap ( ) ) ;
287284 }
288285
289286 #[ test]
@@ -292,6 +289,6 @@ mod tests {
292289
293290 let response = Response :: random ( Opcode :: MapUdp , & mut rng) ;
294291 let encoded = response. encode ( ) ;
295- assert_eq ! ( Ok ( response) , Response :: decode( & encoded) ) ;
292+ assert_eq ! ( response, Response :: decode( & encoded) . unwrap ( ) ) ;
296293 }
297294}
0 commit comments