aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 428ebf9176fffe037e956cc551e4b1d2d0d84efd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
}