Struct gsbrs::GSBClient
[−]
[src]
pub struct GSBClient<'b> { /* fields omitted */ }
A client for interacting with the Google Safe Browsing Lookup API
Methods
impl<'b> GSBClient<'b>
[src]
pub fn new(key: String) -> GSBClient<'b>
[src]
Creates a new GSBClient that will use 'key' as the GSB API key
Arguments
key
- A String that represents the API key for Google Safe Browsing Lookup
Example
use gsbrs::GSBClient; let key : String = "example_api_key".into(); let gsb = GSBClient::new(key);
pub fn change_client_name(&mut self, client_name: &'b str)
[src]
Sets the GSBClient client_name to 'client_name' GSBClient uses 'gsbrs' as the client_name by default.
Arguments
client_name
- A string slice that holds the name of the org/person using the client
Example
let key : String = "example_api_key".into(); let mut gsb = gsbrs::GSBClient::new(key); gsb.change_client_name("new_name");
pub fn get_client_mut(&mut self) -> &mut Client
[src]
Returns a mutable reference to the hyper::Client used for connections
pub fn lookup(&self, url: &str) -> Result<Vec<Status>, GSBError>
[src]
Queries GSB API with 'url', returns Vec of Status for 'url'
Arguments
url
- A string slice that holds the url to be queried
Example
let key : String = "example_api_key".into();
let gsb = gsbrs::GSBClient::new(key);
let url = "https://google.com/";
if let Ok(statuses) = gsb.lookup(url) {
assert_eq!(statuses[0], Status::Ok)
};
pub fn lookup_all<'a, I>(&self, urls: I) -> Result<Vec<Vec<Status>>, GSBError> where
I: Iterator<Item = &'a str>,
[src]
I: Iterator<Item = &'a str>,
Perform a bulk lookup on an iterable of urls. Returns a Vector of Vectors containing Statuses. Returns GSBError::TooManyUrls if > 500 urls are pased in
Arguments
urls
- An iterable of string slices representing URLs to query
Example
let key : String = "example_api_key".into();
let gsb = GSBClient::new(key);
let urls = vec!["https://google.com/", "https://example.com"];
gsb.lookup_all(urls.iter());