Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
0xIchigo committed Apr 24, 2024
1 parent 89685fa commit 7c3d472
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::error::{ HeliusError, Result };
use crate::error::{HeliusError, Result};
use crate::types::{Cluster, HeliusEndpoints};

#[derive(Clone)]
Expand Down
18 changes: 9 additions & 9 deletions src/request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ impl RequestHandler {
let status: StatusCode = response.status();
let path: String = response.url().path().to_string();
let body_text: String = response.text().await.unwrap_or_default();

println!("Response status: {}, Body: {}", status, body_text);

if status.is_success() {
match serde_json::from_str::<T>(&body_text) {
Ok(data) => Ok(data),
Expand All @@ -51,13 +51,13 @@ impl RequestHandler {
}
} else {
let body_json: serde_json::Result<serde_json::Value> = serde_json::from_str(&body_text);
match body_json {
Ok(body) => {
let error_message: String = body["message"].as_str().unwrap_or("Unknown error").to_string();
Err(HeliusError::from_response_status(status, path, error_message))
},
Err(_) => Err(HeliusError::from_response_status(status, path, body_text)),
}
match body_json {
Ok(body) => {
let error_message: String = body["message"].as_str().unwrap_or("Unknown error").to_string();
Err(HeliusError::from_response_status(status, path, error_message))
}
Err(_) => Err(HeliusError::from_response_status(status, path, body_text)),
}
}
}
}
2 changes: 1 addition & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pub mod enums;
pub mod types;

pub use self::enums::{AssetSortBy, AssetSortDirection};
pub use self::types::{AssetsByOwnerRequest, Cluster, GetAssetResponseList, HeliusEndpoints};
pub use self::types::{ApiResponse, AssetsByOwnerRequest, Cluster, GetAssetResponseList, HeliusEndpoints};
2 changes: 1 addition & 1 deletion src/types/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub struct ApiResponse {
#[serde(untagged)]
pub enum ResponseType {
#[default]
DefaultResponse, // This is a placeholder for the default response type. TODO: Replace this an appropriate type
DefaultResponse, // This is a placeholder for the default response type. TODO: Replace this an appropriate type
GetAssetResponseList(GetAssetResponseList),
}

Expand Down

0 comments on commit 7c3d472

Please sign in to comment.