Skip to content

Commit f3bd3ad

Browse files
fix: resolve clippy linting issues in Hermes Rust client
Co-Authored-By: Tejas Badadare <[email protected]>
1 parent d10e5e9 commit f3bd3ad

File tree

6 files changed

+35
-34
lines changed

6 files changed

+35
-34
lines changed

apps/hermes/client/rust/src/apis/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ enum ContentType {
102102
impl From<&str> for ContentType {
103103
fn from(content_type: &str) -> Self {
104104
if content_type.starts_with("application") && content_type.contains("json") {
105-
return Self::Json;
105+
Self::Json
106106
} else if content_type.starts_with("text/plain") {
107-
return Self::Text;
107+
Self::Text
108108
} else {
109-
return Self::Unsupported(content_type.to_string());
109+
Self::Unsupported(content_type.to_string())
110110
}
111111
}
112112
}

apps/hermes/client/rust/src/apis/rest_api.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ pub async fn get_price_feed(configuration: &configuration::Configuration, id: &s
143143
let content = resp.text().await?;
144144
match content_type {
145145
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
146-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RpcPriceFeed`"))),
147-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RpcPriceFeed`")))),
146+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RpcPriceFeed`"))),
147+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RpcPriceFeed`")))),
148148
}
149149
} else {
150150
let content = resp.text().await?;
@@ -183,8 +183,8 @@ pub async fn get_vaa(configuration: &configuration::Configuration, id: &str, pub
183183
let content = resp.text().await?;
184184
match content_type {
185185
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
186-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetVaaResponse`"))),
187-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetVaaResponse`")))),
186+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetVaaResponse`"))),
187+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetVaaResponse`")))),
188188
}
189189
} else {
190190
let content = resp.text().await?;
@@ -221,8 +221,8 @@ pub async fn get_vaa_ccip(configuration: &configuration::Configuration, data: st
221221
let content = resp.text().await?;
222222
match content_type {
223223
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
224-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetVaaCcipResponse`"))),
225-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetVaaCcipResponse`")))),
224+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetVaaCcipResponse`"))),
225+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetVaaCcipResponse`")))),
226226
}
227227
} else {
228228
let content = resp.text().await?;
@@ -270,8 +270,8 @@ pub async fn latest_price_feeds(configuration: &configuration::Configuration, id
270270
let content = resp.text().await?;
271271
match content_type {
272272
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
273-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::RpcPriceFeed&gt;`"))),
274-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::RpcPriceFeed&gt;`")))),
273+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::RpcPriceFeed&gt;`"))),
274+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::RpcPriceFeed&gt;`")))),
275275
}
276276
} else {
277277
let content = resp.text().await?;
@@ -323,8 +323,8 @@ pub async fn latest_price_updates(configuration: &configuration::Configuration,
323323
let content = resp.text().await?;
324324
match content_type {
325325
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
326-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PriceUpdate`"))),
327-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PriceUpdate`")))),
326+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PriceUpdate`"))),
327+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PriceUpdate`")))),
328328
}
329329
} else {
330330
let content = resp.text().await?;
@@ -367,8 +367,8 @@ pub async fn latest_publisher_stake_caps(configuration: &configuration::Configur
367367
let content = resp.text().await?;
368368
match content_type {
369369
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
370-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LatestPublisherStakeCapsUpdateDataResponse`"))),
371-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LatestPublisherStakeCapsUpdateDataResponse`")))),
370+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LatestPublisherStakeCapsUpdateDataResponse`"))),
371+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LatestPublisherStakeCapsUpdateDataResponse`")))),
372372
}
373373
} else {
374374
let content = resp.text().await?;
@@ -421,8 +421,8 @@ pub async fn latest_twaps(configuration: &configuration::Configuration, window_s
421421
let content = resp.text().await?;
422422
match content_type {
423423
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
424-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwapsResponse`"))),
425-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwapsResponse`")))),
424+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TwapsResponse`"))),
425+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TwapsResponse`")))),
426426
}
427427
} else {
428428
let content = resp.text().await?;
@@ -462,8 +462,8 @@ pub async fn latest_vaas(configuration: &configuration::Configuration, ids_left_
462462
let content = resp.text().await?;
463463
match content_type {
464464
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
465-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;String&gt;`"))),
466-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;String&gt;`")))),
465+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;String&gt;`"))),
466+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;String&gt;`")))),
467467
}
468468
} else {
469469
let content = resp.text().await?;
@@ -497,8 +497,8 @@ pub async fn price_feed_ids(configuration: &configuration::Configuration, ) -> R
497497
let content = resp.text().await?;
498498
match content_type {
499499
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
500-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;String&gt;`"))),
501-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;String&gt;`")))),
500+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;String&gt;`"))),
501+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;String&gt;`")))),
502502
}
503503
} else {
504504
let content = resp.text().await?;
@@ -541,8 +541,8 @@ pub async fn price_feeds_metadata(configuration: &configuration::Configuration,
541541
let content = resp.text().await?;
542542
match content_type {
543543
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
544-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::PriceFeedMetadata&gt;`"))),
545-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::PriceFeedMetadata&gt;`")))),
544+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::PriceFeedMetadata&gt;`"))),
545+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::PriceFeedMetadata&gt;`")))),
546546
}
547547
} else {
548548
let content = resp.text().await?;
@@ -602,8 +602,8 @@ pub async fn price_stream_sse_handler(configuration: &configuration::Configurati
602602
let content = resp.text().await?;
603603
match content_type {
604604
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
605-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PriceUpdate`"))),
606-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PriceUpdate`")))),
605+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PriceUpdate`"))),
606+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PriceUpdate`")))),
607607
}
608608
} else {
609609
let content = resp.text().await?;
@@ -656,8 +656,8 @@ pub async fn timestamp_price_updates(configuration: &configuration::Configuratio
656656
let content = resp.text().await?;
657657
match content_type {
658658
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
659-
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PriceUpdate`"))),
660-
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PriceUpdate`")))),
659+
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PriceUpdate`"))),
660+
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PriceUpdate`")))),
661661
}
662662
} else {
663663
let content = resp.text().await?;

apps/hermes/client/rust/src/models/asset_type.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use crate::models;
1212
use serde::{Deserialize, Serialize};
1313

14-
///
1514
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
1615
pub enum AssetType {
1716
#[serde(rename = "crypto")]

apps/hermes/client/rust/src/models/encoding_type.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use crate::models;
1212
use serde::{Deserialize, Serialize};
1313

14-
///
1514
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
1615
pub enum EncodingType {
1716
#[serde(rename = "hex")]

apps/hermes/client/rust/src/models/sse_event.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,9 @@ impl SseEvent {
3535
}
3636
}
3737
}
38+
39+
impl Default for SseEvent {
40+
fn default() -> Self {
41+
Self::new()
42+
}
43+
}

apps/hermes/client/rust/src/streaming.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub async fn create_price_update_stream(
7272
Ok(sse_event) => {
7373
if let Some(parsed_updates) = sse_event.parsed {
7474
let stream = parsed_updates.into_iter()
75-
.map(|update| Ok(update))
75+
.map(Ok)
7676
.collect::<Vec<Result<ParsedPriceUpdate, Box<dyn Error + Send + Sync>>>>();
7777
Ok(futures_util::stream::iter(stream))
7878
} else {
@@ -88,10 +88,7 @@ pub async fn create_price_update_stream(
8888
.flat_map(|result| {
8989
match result {
9090
Ok(stream) => stream,
91-
Err(e) => {
92-
let err = e;
93-
futures_util::stream::iter(vec![Err(err)])
94-
}
91+
Err(e) => futures_util::stream::iter(vec![Err(e)])
9592
}
9693
});
9794

0 commit comments

Comments
 (0)