[−][src]Struct roy::Client
The HTTP client
Fields
base_url: String
API base URL
Implementations
impl Client
[src]
pub fn new(base_url: String) -> Client
[src]
Create a new instance of a Client
Usage:
use roy::Client; let c = Client::new("https://httpbin.org".to_string()); assert_eq!(c.base_url, "https://httpbin.org");
pub fn new_auth(base_url: String, auth_token: &'static str) -> Client
[src]
Create a new instance of an authenticated Client
Usage:
use roy::Client; use tokio_test::block_on; let c = Client::new_auth("https://httpbin.org".to_string(), ""); assert_eq!(block_on(c.get("/bearer", false)).is_some(), true);
pub async fn post<T: Serialize + Debug, '_, '_>(
&'_ self,
endpoint: &'_ str,
data: T
) -> Option<Response>
[src]
&'_ self,
endpoint: &'_ str,
data: T
) -> Option<Response>
Generic function to POST data to an endpoint
Usage:
use roy::Client; use tokio_test::block_on; let c = Client::new("https://httpbin.org".to_string()); assert_eq!(block_on(c.post("/post", "{data}")).is_some(), true);
pub async fn delete<'_, '_>(&'_ self, endpoint: &'_ str) -> Option<Response>
[src]
Generic function to DELETE to an endpoint
Usage:
use roy::Client; use tokio_test::block_on; let c = Client::new("https://httpbin.org".to_string()); assert_eq!(block_on(c.delete("/delete")).is_some(), true);
pub async fn patch<T: Serialize + Debug, '_, '_>(
&'_ self,
endpoint: &'_ str,
data: T
) -> Option<Response>
[src]
&'_ self,
endpoint: &'_ str,
data: T
) -> Option<Response>
Generic function to PATCH data to an endpoint
Usage:
use roy::Client; use tokio_test::block_on; let c = Client::new("https://httpbin.org".to_string()); assert_eq!(block_on(c.patch("/patch", "{data}")).is_some(), true);
pub async fn put<T: Serialize + Debug, '_, '_>(
&'_ self,
endpoint: &'_ str,
data: T
) -> Option<Response>
[src]
&'_ self,
endpoint: &'_ str,
data: T
) -> Option<Response>
Generic function to PUT data to an endpoint
Usage:
use roy::Client; use tokio_test::block_on; let c = Client::new("https://httpbin.org".to_string()); assert_eq!(block_on(c.put("/put", "{data}")).is_some(), true);
pub async fn get<'_, '_>(
&'_ self,
endpoint: &'_ str,
single: bool
) -> Option<Response>
[src]
&'_ self,
endpoint: &'_ str,
single: bool
) -> Option<Response>
Generic function to send a GET request to an endpoint
Usage:
use roy::Client; use tokio_test::block_on; let c = Client::new("https://httpbin.org".to_string()); assert_eq!(block_on(c.get("/get", false)).is_some(), true);
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,