Compare commits

...

3 commits

Author SHA1 Message Date
Sandor Pecsi
168621cd99
Reverted emulation mode on main 2024-02-28 17:42:06 +00:00
Sandor Pecsi
bcbe002beb
Added dns and http client stubs 2024-02-28 17:41:21 +00:00
xea@blacklight.id
b924e4dc2f Created emulate branch 2024-02-28 16:48:47 +00:00
5 changed files with 54 additions and 23 deletions

2
.gitignore vendored
View file

@ -14,3 +14,5 @@ Cargo.lock
# MSVC Windows builds of rustc generate these, which store debugging information # MSVC Windows builds of rustc generate these, which store debugging information
*.pdb *.pdb
# Vim swapfiles
*.swp

View file

@ -7,7 +7,6 @@ edition = "2021"
[dependencies] [dependencies]
unicorn_hat_hd_2 = { version = "*" } unicorn_hat_hd_2 = { version = "*" }
#unicorn_hat_hd_2 = { version = "*", default-features = false, features = [ "fake-hardware" ] }
url = "*" url = "*"
reqwest = "*" reqwest = "*"
trust-dns-client = "*" trust-dns-client = "*"

13
src/dns.rs Normal file
View file

@ -0,0 +1,13 @@
use crate::{Probe, ProbeResult};
use trust_dns_client::client::Client;
// DNS probe
pub struct DnsProbe {
}
impl Probe for DnsProbe {
fn execute() -> ProbeResult {
unimplemented!();
}
}

31
src/http.rs Normal file
View file

@ -0,0 +1,31 @@
use crate::{Probe, ProbeResult};
use url::Url;
use std::net::SocketAddr;
#[derive(Debug)]
pub enum HttpError {
UrlError(url::ParseError)
}
// HTTP probe
//
pub struct HttpProbe {
remote_addr: SocketAddr
}
impl HttpProbe {
pub fn get(url: &str) -> Result<HttpProbe, HttpError> {
let request = url::Url::parse(url)
.map_err(HttpError::UrlError);
unimplemented!();
}
}
impl Probe for HttpProbe {
fn execute() -> ProbeResult {
unimplemented!();
}
}

View file

@ -1,7 +1,9 @@
use unicorn_hat_hd_2::UnicornHatHd; use unicorn_hat_hd_2::UnicornHatHd;
use url::Url;
use std::net::SocketAddr; use self::http::HttpProbe;
mod dns;
mod http;
pub trait Probe { pub trait Probe {
fn execute() -> ProbeResult; fn execute() -> ProbeResult;
@ -21,26 +23,6 @@ pub struct ProbeMetrics {
pub latency_ms: u32 pub latency_ms: u32
} }
// HTTP probe
//
pub struct HttpProbe {
remote_addr: SocketAddr
}
impl Probe for HttpProbe {
fn execute() -> ProbeResult {
unimplemented!();
}
}
// DNS probe
pub struct DnsProbe {
fn execute() -> ProbeResult {
unimplemented!();
}
}
fn main() { fn main() {
let mut hat_hd = UnicornHatHd::default(); let mut hat_hd = UnicornHatHd::default();
@ -50,5 +32,9 @@ fn main() {
//hat_hd.set_pixel(x, y, [255, 255, 255].into()); //hat_hd.set_pixel(x, y, [255, 255, 255].into());
//hat_hd.display().unwrap(); //hat_hd.display().unwrap();
let probes = vec![
HttpProbe::get("https://google.co.uk").expect("Failed to parse URL")
];
} }