-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
mod config; | ||
mod receive; | ||
mod request; | ||
mod send; | ||
mod utils; | ||
|
||
|
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod clap; | ||
pub mod crossterm; | ||
pub mod handle; | ||
pub mod request; | ||
pub mod select; | ||
pub mod udp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use reqwest::{Client, Url}; | ||
use serde::{Deserialize, Serialize}; | ||
use std::net::SocketAddr; | ||
|
||
#[derive(Deserialize)] | ||
pub struct Receiver { | ||
pub id: String, | ||
pub alias: String, | ||
} | ||
|
||
fn into_url(address: &SocketAddr) -> Url { | ||
let url_string = format!("http://{}", address); | ||
Url::parse(&url_string).expect("invalid address") | ||
} | ||
|
||
#[derive(Deserialize)] | ||
pub struct GetReceiversRes { | ||
pub receivers: Vec<Receiver>, | ||
message: String, | ||
} | ||
|
||
pub async fn get_receivers(address: &SocketAddr) -> Result<GetReceiversRes, reqwest::Error> { | ||
let result = Client::new().get(into_url(address)).send().await?; | ||
Ok(result.json().await.unwrap()) | ||
} |