pub struct Response { /* private fields */ }
Expand description
A response from Elasticsearch
Implementations
sourceimpl Response
impl Response
sourcepub fn new(response: Response, method: Method) -> Self
pub fn new(response: Response, method: Method) -> Self
Creates a new instance of an Elasticsearch response
sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Get the response content-length, if known.
Reasons it may not be known:
- The server didn’t send a
content-length
header. - The response is compressed and automatically decoded (thus changing the actual decoded length).
sourcepub fn content_type(&self) -> &str
pub fn content_type(&self) -> &str
Gets the response content-type.
sourcepub fn error_for_status_code(self) -> Result<Self, ClientError>
pub fn error_for_status_code(self) -> Result<Self, ClientError>
Turn the response into an Error if Elasticsearch returned an error.
sourcepub fn error_for_status_code_ref(&self) -> Result<&Self, ClientError>
pub fn error_for_status_code_ref(&self) -> Result<&Self, ClientError>
Turn the response into an Error if Elasticsearch returned an error.
sourcepub async fn exception(self) -> Result<Option<Exception>, ClientError>
pub async fn exception(self) -> Result<Option<Exception>, ClientError>
Asynchronously reads the response body into an Exception if Elasticsearch returned a HTTP status code in the 400-599 range.
Reading the response body consumes self
sourcepub async fn json<B>(self) -> Result<B, ClientError> where
B: DeserializeOwned,
pub async fn json<B>(self) -> Result<B, ClientError> where
B: DeserializeOwned,
Asynchronously reads the response body as JSON
Reading the response body consumes self
sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
Get the HTTP status code of the response
sourcepub async fn text(self) -> Result<String, ClientError>
pub async fn text(self) -> Result<String, ClientError>
Asynchronously reads the response body as plain text
Reading the response body consumes self
sourcepub async fn bytes(self) -> Result<Bytes, ClientError>
pub async fn bytes(self) -> Result<Bytes, ClientError>
Asynchronously reads the response body as bytes
Reading the response body consumes self
sourcepub fn warning_headers(&self) -> impl Iterator<Item = &str>
pub fn warning_headers(&self) -> impl Iterator<Item = &str>
Gets the Deprecation warning response headers
Deprecation headers signal the use of Elasticsearch functionality or features that are deprecated and will be removed in a future release.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl !UnwindSafe for Response
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more