27 lines
668 B
Rust
27 lines
668 B
Rust
use cursive::Cursive;
|
|
use reqwest;
|
|
use crate::types::Channel;
|
|
|
|
pub async fn fetch_channels(domain: &str, port: u16) -> Option<Vec<Channel>>{
|
|
let url = format!("http://{}:{}/channels/list", domain, port);
|
|
|
|
if let Ok(resp) = reqwest::get(&url).await {
|
|
let bytes = resp.bytes().await.unwrap();
|
|
let res: Result<Vec<Channel>, serde_json::Error> = serde_json::from_slice(&bytes);
|
|
return match res {
|
|
Ok(res) => Some(res),
|
|
_ => None
|
|
};
|
|
}
|
|
return None;
|
|
}
|
|
|
|
|
|
pub mod sync {
|
|
use cursive::Cursive;
|
|
use std::net::Ipv4Addr;
|
|
|
|
pub fn open_channel(ip: Ipv4Addr, name: &str, s: &mut Cursive) {
|
|
}
|
|
|
|
} |