pub struct ApiResponse {
pub status_code: u16,
pub headers: HashMap<String, String>,
pub body: Vec<u8>,
pub execution_time: Duration,
}Expand description
HTTP response representation
Fields§
§status_code: u16§headers: HashMap<String, String>§body: Vec<u8>§execution_time: DurationImplementations§
Source§impl ApiResponse
impl ApiResponse
pub fn new(status_code: u16, body: Vec<u8>, execution_time: Duration) -> Self
pub fn with_headers(self, headers: HashMap<String, String>) -> Self
pub fn is_success(&self) -> bool
pub fn text(&self) -> Result<String, ApiError>
pub fn json<T: for<'de> Deserialize<'de>>(&self) -> Result<T, ApiError>
pub fn get_header(&self, name: &str) -> Option<&String>
Trait Implementations§
Source§impl Clone for ApiResponse
impl Clone for ApiResponse
Source§fn clone(&self) -> ApiResponse
fn clone(&self) -> ApiResponse
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 ApiResponse
impl RefUnwindSafe for ApiResponse
impl Send for ApiResponse
impl Sync for ApiResponse
impl Unpin for ApiResponse
impl UnwindSafe for ApiResponse
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more