Crates.io | rust_ipify |
lib.rs | rust_ipify |
version | 1.1.0 |
source | src |
created_at | 2021-07-08 17:45:07.041937 |
updated_at | 2021-07-09 12:40:14.494346 |
description | A rust client library for ipify |
homepage | https://github.com/ZigRazor/rust_ipify |
repository | https://github.com/ZigRazor/rust_ipify |
max_upload_size | |
id | 420410 |
size | 44,907 |
A rust client library for ipify
Rust ipify is a client library in Rust language for ipify.
Ever needed to get your public IP address programmatically? Maybe you're provisioning new cloud servers and need to know your IP -- maybe you're behind a corporate firewall and need to tunnel information -- whatever the reason: sometimes having a public IP address API is useful!
You should use ipify because:
You can use it without limit (even if you're doing millions of requests per minute.
It works flawlessly with both IPv4 and IPv6 addresses, so no matter what sort of technology you're using, there won't be issues.
It's always online and available, and its infrastructure is powered by Heroku, which means that regardless of whether the server running the API dies, or if there's an enormous tornado which destroys half of the east coast, ipify will still be running!
ipify is completely open source (check out the GitHub repository).
No visitor information is ever logged. Period.
Lastly, ipify is funded by Randall Degges, so there's no need to worry about the domain name disappearing in three years or anything like that: ipify is here to stay!
The library requires the Rust Edition >= 2018
The repository contains 2 folder. The first one Rust_ipify_lib contains the sources of the library, the second one Rust_ipify_lib_test contains the sources of the test.
cd Rust_ipify_lib
cargo build
cd Rust_ipify_lib_test
cargo build
cd Rust_ipify_lib_test
cargo run
The example is provided under the Rust_ipify_lib_test/src/
folder.
The file contains an example of usage of the API of the library to retrive the global IP:
extern crate rust_ipify;
use rust_ipify::ipify::get_ip_json;
use rust_ipify::ipify::get_ip_string;
use rust_ipify::ipify::get_ip4_json;
use rust_ipify::ipify::get_ip4_string;
use rust_ipify::ipify::get_ip4_i32;
use rust_ipify::ipify::get_ip_i128;
fn main() {
println!("inside main of test ");
let result_ip64_json = get_ip_json();
match result_ip64_json {
Ok(r) => println!("Result IP ( JSON ): \n{:#?}\n", r),
Err(e) => println!("error in request {:?}", e),
}
let result_ip64_string = get_ip_string();
match result_ip64_string {
Ok(r) => println!("Result IP ( String ): \n\t{:#?}\n", r),
Err(e) => println!("error in request {:?}", e),
}
let result_ip4_json = get_ip4_json();
match result_ip4_json {
Ok(r) => println!("Result IP v4 ( JSON ): \n{:#?}\n", r),
Err(e) => println!("error in request {:?}", e),
}
let result_ip4_string = get_ip4_string();
match result_ip4_string {
Ok(r) => println!("Result IP v4 ( String ): \n\t{:#?}\n", r),
Err(e) => println!("error in request {:?}", e),
}
let result_ip4_i32 = get_ip4_i32();
match result_ip4_i32 {
Ok(r) => println!("Result IP v4 ( i32 ): \n\t{:#?}\n", r),
Err(e) => println!("error in request {:?}", e),
}
let result_ip_i128 = get_ip_i128();
match result_ip_i128 {
Ok(r) => println!("Result IP ( i128 ): \n\t{:#?}\n", r),
Err(e) => println!("error in request {:?}", e),
}
If you want give your support you can create a pull request
If you want to change the code, or fix issue, or implement a new feature please read our CONTRIBUTING Guide.
Checkout last released version from Crates.io Site here
E-Mail : zigrazor@gmail.com