pub struct Client<'a> {
pub sender: Option<&'a Account>,
/* private fields */
}Expand description
Client object for interacting with the API
You are forced to use this as a proxy for authentication: it is essentially
a factory, but named for convenience (I think). A Client object can be
constructed the constructors [new], [from_auth], [from_basic_auth],
or [from_apikey].
Creates a synchronous (currently) client. Optimistically, we will implement an async version through tokio, but I have absolutely no idea what that entails.
§Examples
This example details the basic task of retrieving a quote from the Transdirect API.
#[ignore]
use transdirect::{TransdirectClient, BookingRequest};Fields§
§sender: Option<&'a Account>Implementations§
Source§impl<'a> Client<'a>
impl<'a> Client<'a>
pub fn new() -> Self
pub fn from_auth(auth: AuthenticateWith<'_>) -> Result<Self, Error>
pub fn from_basic(user: &str, password: &str) -> Result<Self, Error>
pub fn from_api_key(apikey: &str) -> Result<Self, Error>
pub fn auth(&mut self, auth: AuthenticateWith<'_>) -> Result<(), Error>
pub fn quotes<'b, T, U>( &self, request: &'b BookingRequest<'_, T, U>, ) -> Result<BookingResponse<T, U>, Error>
Sourcepub fn booking<T, U>(
&self,
booking_id: u32,
) -> Result<BookingResponse<T, U>, Error>
pub fn booking<T, U>( &self, booking_id: u32, ) -> Result<BookingResponse<T, U>, Error>
Gets a copy of a booking from its id; note that this is different from its connote (consignment note or tracking number).
§Examples
use transdirect::BookingResponse;
use transdirect::TransdirectClient as Client;
let c = Client::new();
//...
let oldbooking: BookingResponse = c.booking(623630).expect("Valid booking");
// Do something interestingAuto Trait Implementations§
impl<'a> !Freeze for Client<'a>
impl<'a> !RefUnwindSafe for Client<'a>
impl<'a> Send for Client<'a>
impl<'a> Sync for Client<'a>
impl<'a> Unpin for Client<'a>
impl<'a> !UnwindSafe for Client<'a>
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