pub struct AllowanceCheckURLBuilder {}Expand description
Builder for AllowanceCheckURL.
Implementations§
Source§impl AllowanceCheckURLBuilder
impl AllowanceCheckURLBuilder
Sourcepub fn build(&self) -> Result<AllowanceCheckURL, AllowanceCheckURLBuilderError>
pub fn build(&self) -> Result<AllowanceCheckURL, AllowanceCheckURLBuilderError>
Examples found in repository?
examples/normal.rs (line 9)
8fn main() {
9 let api = AllowanceCheckURLBuilder::default().build().unwrap();
10 // Need to import the Endpoint trait
11 let response = ureq::request(api.method(), api.url().unwrap().as_str())
12 .set(TOKEN_KEY, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
13 .call();
14 match handle_ureq_response::<AllowanceCheck>(response) {
15 Ok(allowance) => {
16 println!(
17 "You have made {} API calls today",
18 allowance.allowance.count
19 );
20 }
21 Err(e) => {
22 eprintln!("Error: {}", e);
23 }
24 }
25}More examples
examples/custom_env.rs (line 12)
9fn main() {
10 match get_token_from_env(Some("MY_CUSTOM_KEY")) {
11 Ok(val) => {
12 let api = AllowanceCheckURLBuilder::default().build().unwrap();
13 // Need to import the Endpoint trait
14 let response = ureq::request(api.method(), api.url().unwrap().as_str())
15 .set(TOKEN_KEY, &val)
16 .call();
17 match handle_ureq_response::<AllowanceCheck>(response) {
18 Ok(status) => {
19 println!("{:?}", status);
20 }
21 Err(e) => {
22 eprintln!("Error: {}", e);
23 }
24 }
25 }
26 Err(e) => panic!("Environment variable error: {}", e),
27 }
28}examples/normal_reqwest.rs (line 10)
9fn main() {
10 let api = AllowanceCheckURLBuilder::default().build().unwrap();
11 // Need to import the Endpoint trait
12 let mut headers = header::HeaderMap::new();
13 headers.insert(
14 TOKEN_KEY,
15 header::HeaderValue::from_str("XXXXXXXXXXXXXXXXXXXXXXX").unwrap(),
16 );
17 let client = reqwest::blocking::ClientBuilder::new()
18 .default_headers(headers)
19 .build()
20 .unwrap();
21 let response = client.get(api.url().unwrap().as_str()).send();
22 match handle_reqwest_response_blocking::<AllowanceCheck>(response) {
23 Ok(allowance) => {
24 println!(
25 "You have made {} API calls today",
26 allowance.allowance.count
27 );
28 }
29 Err(e) => {
30 eprintln!("Error: {}", e);
31 }
32 }
33}Trait Implementations§
Source§impl Clone for AllowanceCheckURLBuilder
impl Clone for AllowanceCheckURLBuilder
Source§fn clone(&self) -> AllowanceCheckURLBuilder
fn clone(&self) -> AllowanceCheckURLBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AllowanceCheckURLBuilder
impl RefUnwindSafe for AllowanceCheckURLBuilder
impl Send for AllowanceCheckURLBuilder
impl Sync for AllowanceCheckURLBuilder
impl Unpin for AllowanceCheckURLBuilder
impl UnwindSafe for AllowanceCheckURLBuilder
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