Crate gip[][src]

This crate provides a library for checking global IP address. This crate get IP address information from IP address checking services like inet-ip.info, ipify.org, etc.

Usage

This crate can be used by adding gip to your dependencies in Cargo.toml.

[dependencies]
gip = "0.6.0"

and this to your crate root:

extern crate gip;

Example

Provider trait provide get_addr function to check global IP address. ProviderDefaultV4 is a Provider implementation with built-in providers for IPv4 address.

use gip::{Provider, ProviderDefaultV4};
let mut p = ProviderDefaultV4::new();
let addr = p.get_addr();
match addr {
    Ok(x) => println!( "Global IPv4 address is {:?}", x.v4addr ),
    Err(_) => (),
}

ProviderDefaultV6 is for IPv6 address.

use gip::{Provider, ProviderDefaultV6};
let mut p = ProviderDefaultV6::new();
let addr = p.get_addr();
match addr {
    Ok(x) => println!( "Global IPv6 address is {:?}", x.v6addr ),
    Err(_) => (),
}

ProviderDefaultV4 and ProviderDefaultV6 tries the next provider if a provider is failed to access. So get_addr successes unless all providers failed.

Built-in providers

ProviderDefaultV4 and ProviderDefaultV6 use the built-in provider list ( defined as DEFAULT_TOML ):

Structs

Error

The Error type.

GlobalAddress

Global address information

ProviderAny

A Provider implementation to try multiple providers

ProviderDefaultV4

A convinient wrapper of ProviderAny with default providers for IPv4

ProviderDefaultV6

A convinient wrapper of ProviderAny with default providers for IPv6

ProviderInfo

Provider information

ProviderInfoList

Provider information list

ProviderJson

A Provider implementation for checking global address by JSON format.

ProviderPlane

A Provider implementation for checking global address by plane text format.

Enums

ErrorKind

The kind of an error.

ProviderInfoFormat

Format of return value from provider

ProviderInfoType

Type of global address from provider

Statics

DEFAULT_TOML

Built-in providers list

Traits

Provider

Provider describes types that can provide global address information

ResultExt

Additional methods for Result, for easy interaction with this crate.

Type Definitions

Result

Convenient wrapper around std::Result.