pub struct GSBClient<'b> { /* private fields */ }
Expand description
A client for interacting with the Google Safe Browsing Lookup API
Implementations§
Source§impl<'b> GSBClient<'b>
impl<'b> GSBClient<'b>
Sourcepub fn change_client_name(&mut self, client_name: &'b str)
pub fn change_client_name(&mut self, client_name: &'b str)
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");
Sourcepub fn get_client_mut(&mut self) -> &mut Client
pub fn get_client_mut(&mut self) -> &mut Client
Returns a mutable reference to the hyper::Client used for connections
Sourcepub fn lookup(&self, url: &str) -> Result<Vec<Status>, GSBError>
pub fn lookup(&self, url: &str) -> Result<Vec<Status>, GSBError>
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)
};
Sourcepub fn lookup_all<'a, I>(&self, urls: I) -> Result<Vec<Vec<Status>>, GSBError>
pub fn lookup_all<'a, I>(&self, urls: I) -> Result<Vec<Vec<Status>>, GSBError>
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());
Auto Trait Implementations§
impl<'b> Freeze for GSBClient<'b>
impl<'b> !RefUnwindSafe for GSBClient<'b>
impl<'b> Send for GSBClient<'b>
impl<'b> Sync for GSBClient<'b>
impl<'b> Unpin for GSBClient<'b>
impl<'b> !UnwindSafe for GSBClient<'b>
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