diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 26 |
1 files changed, 26 insertions, 0 deletions
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<IpAddr, Box<dyn Error>> { + 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; +} |
