pub struct Ipify {
pub t: Op,
pub endp: String,
}
Expand description
The main API struct
Fields§
§t: Op
Current type of operation
endp: String
Endpoint, different for every operation
Implementations§
source§impl Ipify
impl Ipify
API Implementation
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new API instance client with the defaults
Example:
use ipify_rs::*;
let a = Ipify::new();
println!("{}", a.call());
sourcepub fn set(&self, op: Op) -> Self
pub fn set(&self, op: Op) -> Self
Specify the subsequent operation to perform on call()
Examples:
use ipify_rs::{Ipify, Op};
let mut a = Ipify::new();
a.set(Op::IPv6J);
println!("{}", a.call());
sourcepub fn call(self) -> String
pub fn call(self) -> String
Actually perform the API call
Example:
use ipify_rs::Ipify;
let r = Ipify::new().call();
println!("my ip = {}", r);
sourcepub async fn call_async(self) -> String
pub async fn call_async(self) -> String
Actually perform the API call (async version)
Example:
use ipify_rs::Ipify;
async {
let r = Ipify::new().call_async().await;
println!("my ip = {}", r);
}
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Ipify
impl Send for Ipify
impl Sync for Ipify
impl Unpin for Ipify
impl UnwindSafe for Ipify
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more