perf: ⚡ optimized data packets 100%
This commit is contained in:
parent
1cebc9d060
commit
eb62dbd023
5 changed files with 61 additions and 29 deletions
|
@ -20,12 +20,14 @@ impl Server {
|
|||
pub enum Coin {
|
||||
Tail,
|
||||
Head,
|
||||
Dead,
|
||||
}
|
||||
impl Coin {
|
||||
pub fn to_string(&mut self) -> String {
|
||||
match self {
|
||||
Self::Head => String::from("Head"),
|
||||
Self::Tail => String::from("Tail"),
|
||||
Self::Dead => String::from("Dead"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,11 +75,22 @@ pub async fn server_status_check(
|
|||
}
|
||||
}
|
||||
}
|
||||
pub async fn coin_status_check(server_address: &String) -> Result<CoinStatus, reqwest::Error> {
|
||||
Ok(reqwest::get(format!("{}{}", server_address, "/coin"))
|
||||
.await
|
||||
.unwrap()
|
||||
.json::<CoinStatus>()
|
||||
.await
|
||||
.unwrap())
|
||||
pub async fn coin_status_check(server_address: &String) -> Option<CoinStatus> {
|
||||
match reqwest::get(format!("{}{}", server_address, "/coin")).await {
|
||||
Ok(response) => {
|
||||
match response.json::<CoinStatus>().await {
|
||||
Ok(coin_status)=> {
|
||||
Some(coin_status)
|
||||
}
|
||||
Err(err_val) => {
|
||||
log::error!("Error: Can't Deserialise -> {}", err_val);
|
||||
None
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(err_val) => {
|
||||
log::error!("Error: Response from Server -> {}", err_val);
|
||||
None
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue