@@ -326,17 +326,70 @@ pub struct PriceFeedMetadata {
326
326
}
327
327
328
328
#[ derive( Debug , Serialize , Deserialize , PartialEq , ToSchema ) ]
329
- #[ serde( rename_all = "lowercase" ) ]
330
329
pub enum AssetType {
331
330
Crypto ,
332
331
FX ,
333
332
Equity ,
334
- Metals ,
333
+ Metal ,
335
334
Rates ,
335
+ #[ serde( rename = "Crypto Redemption Rate" ) ]
336
+ CryptoRedemptionRate ,
336
337
}
337
338
338
339
impl Display for AssetType {
339
340
fn fmt ( & self , f : & mut Formatter ) -> FmtResult {
340
- write ! ( f, "{:?}" , self )
341
+ match self {
342
+ AssetType :: Crypto => write ! ( f, "Crypto" ) ,
343
+ AssetType :: FX => write ! ( f, "FX" ) ,
344
+ AssetType :: Equity => write ! ( f, "Equity" ) ,
345
+ AssetType :: Metal => write ! ( f, "Metal" ) ,
346
+ AssetType :: Rates => write ! ( f, "Rates" ) ,
347
+ AssetType :: CryptoRedemptionRate => write ! ( f, "Crypto Redemption Rate" ) ,
348
+ }
349
+ }
350
+ }
351
+
352
+ #[ cfg( test) ]
353
+ mod tests {
354
+ use super :: * ;
355
+
356
+ #[ test]
357
+ fn test_serialize_matches_display ( ) {
358
+ assert_eq ! (
359
+ AssetType :: Crypto . to_string( ) ,
360
+ serde_json:: to_string( & AssetType :: Crypto )
361
+ . unwrap( )
362
+ . trim_matches( '"' )
363
+ ) ;
364
+ assert_eq ! (
365
+ AssetType :: FX . to_string( ) ,
366
+ serde_json:: to_string( & AssetType :: FX )
367
+ . unwrap( )
368
+ . trim_matches( '"' )
369
+ ) ;
370
+ assert_eq ! (
371
+ AssetType :: Equity . to_string( ) ,
372
+ serde_json:: to_string( & AssetType :: Equity )
373
+ . unwrap( )
374
+ . trim_matches( '"' )
375
+ ) ;
376
+ assert_eq ! (
377
+ AssetType :: Metal . to_string( ) ,
378
+ serde_json:: to_string( & AssetType :: Metal )
379
+ . unwrap( )
380
+ . trim_matches( '"' )
381
+ ) ;
382
+ assert_eq ! (
383
+ AssetType :: Rates . to_string( ) ,
384
+ serde_json:: to_string( & AssetType :: Rates )
385
+ . unwrap( )
386
+ . trim_matches( '"' )
387
+ ) ;
388
+ assert_eq ! (
389
+ AssetType :: CryptoRedemptionRate . to_string( ) ,
390
+ serde_json:: to_string( & AssetType :: CryptoRedemptionRate )
391
+ . unwrap( )
392
+ . trim_matches( '"' )
393
+ ) ;
341
394
}
342
395
}
0 commit comments