#[non_exhaustive]pub struct Response {
pub status: u16,
pub retry_after: Option<Duration>,
pub body: Vec<u8>,
}Expand description
The parts of an HTTP response that the Flare client needs: the status, the retry time and the body.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.status: u16The HTTP status code.
retry_after: Option<Duration>How long the server asks the Flare client to wait before it tries again.
Comes from the Retry-After header.
body: Vec<u8>The response body. In debug mode, the Flare client reads the partial success of an OTLP response from it, and prints the body of a failed request.
Implementations§
Source§impl Response
impl Response
Sourcepub fn with_retry_after_header(self, value: &str) -> Self
pub fn with_retry_after_header(self, value: &str) -> Self
Reads the wait time from the value of a Retry-After header.
The value can be a number of seconds or an HTTP date. An invalid value is ignored. A date in the past means no wait.
§Examples
use std::time::Duration;
use flareapp_core::Response;
let seconds = Response::new(429).with_retry_after_header("120");
assert_eq!(seconds.retry_after, Some(Duration::from_secs(120)));
let date = Response::new(503).with_retry_after_header("Wed, 21 Oct 2015 07:28:00 GMT");
assert_eq!(date.retry_after, Some(Duration::ZERO));
let invalid = Response::new(503).with_retry_after_header("soon");
assert_eq!(invalid.retry_after, None);Trait Implementations§
impl Eq for Response
impl StructuralPartialEq for Response
Auto Trait Implementations§
impl Forget for Response
impl Freeze for Response
impl Move for Response
impl RefUnwindSafe for Response
impl Send for Responsewhere
RawVecInner: Send,
impl Sync for Responsewhere
RawVecInner: Sync,
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Responsewhere
RawVecInner: 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