pub struct ApiClient { /* private fields */ }Expand description
API client for making requests to the backend
Implementations§
Source§impl ApiClient
impl ApiClient
Sourcepub fn new(base_url: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>) -> Self
Create a new API client with the given base URL
Sourcepub fn local() -> Self
pub fn local() -> Self
Create a client pointing to the default local server (proxied through Trunk)
Sourcepub async fn get<T: DeserializeOwned>(&self, path: &str) -> ApiResult<T>
pub async fn get<T: DeserializeOwned>(&self, path: &str) -> ApiResult<T>
Make a GET request
Sourcepub async fn get_with_query<T: DeserializeOwned, Q: Serialize>(
&self,
path: &str,
query: &Q,
) -> ApiResult<T>
pub async fn get_with_query<T: DeserializeOwned, Q: Serialize>( &self, path: &str, query: &Q, ) -> ApiResult<T>
Make a GET request with query parameters
Sourcepub async fn post<T: DeserializeOwned, B: Serialize>(
&self,
path: &str,
body: &B,
) -> ApiResult<T>
pub async fn post<T: DeserializeOwned, B: Serialize>( &self, path: &str, body: &B, ) -> ApiResult<T>
Make a POST request with JSON body
Sourcepub async fn post_no_response<B: Serialize>(
&self,
path: &str,
body: &B,
) -> ApiResult<()>
pub async fn post_no_response<B: Serialize>( &self, path: &str, body: &B, ) -> ApiResult<()>
Make a POST request without expecting a response body
Sourcepub async fn put<T: DeserializeOwned, B: Serialize>(
&self,
path: &str,
body: &B,
) -> ApiResult<T>
pub async fn put<T: DeserializeOwned, B: Serialize>( &self, path: &str, body: &B, ) -> ApiResult<T>
Make a PUT request with JSON body
Sourcepub async fn patch<T: DeserializeOwned, B: Serialize>(
&self,
path: &str,
body: &B,
) -> ApiResult<T>
pub async fn patch<T: DeserializeOwned, B: Serialize>( &self, path: &str, body: &B, ) -> ApiResult<T>
Make a PATCH request with JSON body
Sourcepub async fn delete_with_response<T: DeserializeOwned>(
&self,
path: &str,
) -> ApiResult<T>
pub async fn delete_with_response<T: DeserializeOwned>( &self, path: &str, ) -> ApiResult<T>
Make a DELETE request expecting a response body
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ApiClient
impl RefUnwindSafe for ApiClient
impl !Send for ApiClient
impl !Sync for ApiClient
impl Unpin for ApiClient
impl UnwindSafe for ApiClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self to a value of a Properties struct.