pub struct ApiRequest<T> {
pub method: Method,
pub path: String,
pub query: Option<String>,
pub body: Option<String>,
pub _marker: PhantomData<T>,
}Expand description
A type-safe API request built by the api! macro.
T is the expected response type, inferred from the OpenAPI spec at compile time.
Fields§
§method: Method§path: String§query: Option<String>§body: Option<String>§_marker: PhantomData<T>Implementations§
Source§impl<T> ApiRequest<T>
impl<T> ApiRequest<T>
pub fn new(method: Method, path: String) -> Self
pub fn query_raw(self, qs: impl Into<String>) -> Self
pub fn body_json(self, body: &impl Serialize) -> Self
Sourcepub fn try_body_json(self, body: &impl Serialize) -> Result<Self, ApiError>
pub fn try_body_json(self, body: &impl Serialize) -> Result<Self, ApiError>
Set a pre-serialized JSON body. Returns an error if serialization fails.
Source§impl<T: DeserializeOwned> ApiRequest<T>
impl<T: DeserializeOwned> ApiRequest<T>
Source§impl ApiRequest<()>
impl ApiRequest<()>
Auto Trait Implementations§
impl<T> Freeze for ApiRequest<T>
impl<T> RefUnwindSafe for ApiRequest<T>where
T: RefUnwindSafe,
impl<T> Send for ApiRequest<T>where
T: Send,
impl<T> Sync for ApiRequest<T>where
T: Sync,
impl<T> Unpin for ApiRequest<T>where
T: Unpin,
impl<T> UnsafeUnpin for ApiRequest<T>
impl<T> UnwindSafe for ApiRequest<T>where
T: UnwindSafe,
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