Skip to content

Commit

Permalink
chore: remove inline
Browse files Browse the repository at this point in the history
  • Loading branch information
ghztomash committed Apr 25, 2024
1 parent f8a5ac6 commit 06e701f
Show file tree
Hide file tree
Showing 21 changed files with 5 additions and 26 deletions.
1 change: 0 additions & 1 deletion src/lookup/abstractapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ impl ProviderResponse<AbstractApiResponse> for AbstractApiResponse {
pub struct AbstractApi;

impl Provider for AbstractApi {
#[inline]
fn get_endpoint(&self, key: &Option<String>, target: &Option<IpAddr>) -> String {
let key = match key {
Some(k) => format!("?api_key={}", k),
Expand Down
2 changes: 0 additions & 2 deletions src/lookup/freeipapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ impl ProviderResponse<FreeIpApiResponse> for FreeIpApiResponse {
pub struct FreeIpApi;

impl Provider for FreeIpApi {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, target: &Option<IpAddr>) -> String {
let target = match target.map(|t| t.to_string()) {
Some(t) => t,
Expand All @@ -62,7 +61,6 @@ impl Provider for FreeIpApi {
format!("https://freeipapi.com/api/json/{}", target)
}

#[inline]
fn add_auth(&self, request: RequestBuilder, key: &Option<String>) -> RequestBuilder {
if let Some(key) = key {
return request.bearer_auth(key);
Expand Down
1 change: 0 additions & 1 deletion src/lookup/getjsonip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ impl ProviderResponse<GetJsonIpResponse> for GetJsonIpResponse {
pub struct GetJsonIp;

impl Provider for GetJsonIp {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, _target: &Option<IpAddr>) -> String {
"https://ipv4.jsonip.com".to_string()
}
Expand Down
1 change: 0 additions & 1 deletion src/lookup/ifconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ impl ProviderResponse<IfConfigResponse> for IfConfigResponse {
pub struct IfConfig;

impl Provider for IfConfig {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, target: &Option<IpAddr>) -> String {
let target = match target.map(|t| t.to_string()) {
Some(t) => format!("?ip={}", t),
Expand Down
1 change: 0 additions & 1 deletion src/lookup/ip2location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ impl ProviderResponse<Ip2LocationResponse> for Ip2LocationResponse {
pub struct Ip2Location;

impl Provider for Ip2Location {
#[inline]
fn get_endpoint(&self, key: &Option<String>, target: &Option<IpAddr>) -> String {
let key = match key {
Some(k) => format!("?key={}", k),
Expand Down
2 changes: 0 additions & 2 deletions src/lookup/ipapico.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ impl ProviderResponse<IpApiCoResponse> for IpApiCoResponse {
pub struct IpApiCo;

impl Provider for IpApiCo {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, target: &Option<IpAddr>) -> String {
let target = match target.map(|t| t.to_string()) {
Some(t) => format!("{}/", t),
Expand All @@ -67,7 +66,6 @@ impl Provider for IpApiCo {
format!("https://ipapi.co/{}json", target)
}

#[inline]
fn add_auth(&self, request: RequestBuilder, _key: &Option<String>) -> RequestBuilder {
request.header("User-Agent", "nil")
}
Expand Down
1 change: 0 additions & 1 deletion src/lookup/ipapicom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ impl ProviderResponse<IpApiComResponse> for IpApiComResponse {
pub struct IpApiCom;

impl Provider for IpApiCom {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, target: &Option<IpAddr>) -> String {
let target = match target.map(|t| t.to_string()) {
Some(t) => t,
Expand Down
1 change: 0 additions & 1 deletion src/lookup/ipapiio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ impl ProviderResponse<IpApiIoResponse> for IpApiIoResponse {
pub struct IpApiIo;

impl Provider for IpApiIo {
#[inline]
fn get_endpoint(&self, key: &Option<String>, target: &Option<IpAddr>) -> String {
let key = match key {
Some(k) => format!("?api_key={}", k),
Expand Down
2 changes: 0 additions & 2 deletions src/lookup/ipbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ impl ProviderResponse<IpBaseResponse> for IpBaseResponse {
pub struct IpBase;

impl Provider for IpBase {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, target: &Option<IpAddr>) -> String {
let target = match target.map(|t| t.to_string()) {
Some(t) => format!("?ip={}", t),
Expand All @@ -133,7 +132,6 @@ impl Provider for IpBase {
format!("https://api.ipbase.com/v2/info{}", target)
}

#[inline]
fn add_auth(&self, request: RequestBuilder, key: &Option<String>) -> RequestBuilder {
if let Some(key) = key {
return request.header("apikey", key);
Expand Down
1 change: 0 additions & 1 deletion src/lookup/ipdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ impl ProviderResponse<IpDataResponse> for IpDataResponse {
pub struct IpData;

impl Provider for IpData {
#[inline]
fn get_endpoint(&self, key: &Option<String>, target: &Option<IpAddr>) -> String {
let key = match key {
Some(k) => format!("?api-key={}", k),
Expand Down
1 change: 0 additions & 1 deletion src/lookup/ipgeolocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ impl ProviderResponse<IpGeolocationResponse> for IpGeolocationResponse {
pub struct IpGeolocation;

impl Provider for IpGeolocation {
#[inline]
fn get_endpoint(&self, key: &Option<String>, target: &Option<IpAddr>) -> String {
let key = match key {
Some(k) => format!("?apiKey={}", k),
Expand Down
1 change: 0 additions & 1 deletion src/lookup/ipify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ impl ProviderResponse<IpifyResponse> for IpifyResponse {
pub struct Ipify;

impl Provider for Ipify {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, _target: &Option<IpAddr>) -> String {
"https://api64.ipify.org/?format=json".to_string()
}
Expand Down
1 change: 0 additions & 1 deletion src/lookup/ipinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ impl ProviderResponse<IpInfoResponse> for IpInfoResponse {
pub struct IpInfo;

impl Provider for IpInfo {
#[inline]
fn get_endpoint(&self, key: &Option<String>, target: &Option<IpAddr>) -> String {
let key = match key {
Some(k) => format!("?token={}", k),
Expand Down
1 change: 0 additions & 1 deletion src/lookup/ipleak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ impl ProviderResponse<IpLeakResponse> for IpLeakResponse {
pub struct IpLeak;

impl Provider for IpLeak {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, target: &Option<IpAddr>) -> String {
let target = match target.map(|t| t.to_string()) {
Some(t) => t,
Expand Down
1 change: 0 additions & 1 deletion src/lookup/iplocateio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ impl ProviderResponse<IpLocateIoResponse> for IpLocateIoResponse {
pub struct IpLocateIo;

impl Provider for IpLocateIo {
#[inline]
fn get_endpoint(&self, key: &Option<String>, target: &Option<IpAddr>) -> String {
let key = match key {
Some(k) => format!("?apikey={}", k),
Expand Down
1 change: 0 additions & 1 deletion src/lookup/ipwhois.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ impl ProviderResponse<IpWhoIsResponse> for IpWhoIsResponse {
pub struct IpWhoIs;

impl Provider for IpWhoIs {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, target: &Option<IpAddr>) -> String {
let target = target.map(|t| t.to_string()).unwrap_or_default();
format!("https://ipwho.is/{}", target)
Expand Down
1 change: 0 additions & 1 deletion src/lookup/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub struct Mock {
}

impl Provider for Mock {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, _target: &Option<IpAddr>) -> String {
"https://httpbin.org/status/200".to_string()
}
Expand Down
8 changes: 5 additions & 3 deletions src/lookup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ pub trait Provider {
/// Returns the type enum of the provider
fn get_type(&self) -> LookupProvider;

#[inline]
/// Returns a request client for the provider
fn get_client(&self, key: Option<String>, target: Option<IpAddr>) -> RequestBuilder {
let client = Client::new().get(self.get_endpoint(&key, &target));
self.add_auth(client, &key)
}

#[inline]
/// Add authentication header to the request
fn add_auth(&self, request: RequestBuilder, _key: &Option<String>) -> RequestBuilder {
request
Expand Down Expand Up @@ -397,7 +395,11 @@ mod tests {
let address = "1.1.1.1".parse::<std::net::IpAddr>().unwrap();
let provider = LookupService::new(LookupProvider::MyIp, None);
let response = provider.lookup(Some(address)).await.unwrap_err();
assert_eq!(response.to_string(), "Target lookup not supported", "Target lookup should fail");
assert_eq!(
response.to_string(),
"Target lookup not supported",
"Target lookup should fail"
);
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion src/lookup/mullvad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ impl ProviderResponse<MullvadResponse> for MullvadResponse {
pub struct Mullvad;

impl Provider for Mullvad {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, _target: &Option<IpAddr>) -> String {
"https://am.i.mullvad.net/json".to_string()
}
Expand Down
1 change: 0 additions & 1 deletion src/lookup/myip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ impl ProviderResponse<MyIpResponse> for MyIpResponse {
pub struct MyIp;

impl Provider for MyIp {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, _target: &Option<IpAddr>) -> String {
"https://api.my-ip.io/v2/ip.json".to_string()
}
Expand Down
1 change: 0 additions & 1 deletion src/lookup/myipcom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ impl ProviderResponse<MyIpComResponse> for MyIpComResponse {
pub struct MyIpCom;

impl Provider for MyIpCom {
#[inline]
fn get_endpoint(&self, _key: &Option<String>, _target: &Option<IpAddr>) -> String {
"https://api.myip.com".to_string()
}
Expand Down

0 comments on commit 06e701f

Please sign in to comment.