From e1f43bb48b23338ce103dc92a53a13e72021299d Mon Sep 17 00:00:00 2001 From: Gus Power Date: Sun, 11 May 2025 15:16:58 +0100 Subject: first pass at ip service w/ happy path test and basic configuration --- src/main.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main.rs (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..428ebf9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,26 @@ +use std::error::Error; +use std::net::IpAddr; +use std::str::FromStr; +use reqwest::Url; + +#[cfg(test)] +mod test; + +fn main() { + println!("Hello, world!"); +} + +pub struct IpService {} + +impl IpService { + + async fn resolve(config: &impl IpServiceConfiguration) -> Result> { + let response = reqwest::get(config.get_service_url()).await.unwrap(); + Ok(IpAddr::from_str(&response.text().await.unwrap())?) + } + +} + +pub trait IpServiceConfiguration { + fn get_service_url(&self) -> Url; +} -- cgit v1.2.3