Skip to main content

Request

Struct Request 

Source
pub struct Request<'a> { /* private fields */ }
Expand description

A request to any Kibana route, created by Kibana::request.

Every endpoint builder wraps one of these. Construction never fails; invalid path segments and serialization errors are returned by send, with the same variant from every clone. Cloning shares the body, so a configured request can be reused cheaply, for example per page.

Implementations§

Source§

impl<'a> Request<'a>

Source

pub fn query<Q: Serialize + ?Sized>(self, query: &Q) -> Self

Appends URL-encoded query parameters serialized from query. Avoid adding a second value for an existing selector or other single-valued parameter; raw query additions do not check for conflicts.

Source

pub fn json<B: Serialize + ?Sized>(self, body: &B) -> Self

Sends body as JSON, replacing any previous body. A body that would repeat an object key, as when a flattened extension map sets a modeled field such as id, fails with Error::InvalidRequest.

This is a raw replacement: it does not reapply the named builder’s selector, concurrency or URL/body identity checks. The caller must retain those fields. An earlier construction error is still returned by send, even if the replacement body would be valid.

Source

pub fn body(self, body: Body) -> Self

Replaces the body without reapplying named-builder checks, as with Self::json. Earlier construction errors still fail at send.

Source

pub fn header(self, name: HeaderName, value: HeaderValue) -> Self

Sets a header on this request only. It replaces every value of the same name from the transport defaults or the body, including Content-Type.

Source

pub fn request_timeout(self, timeout: Duration) -> Self

Overrides the transport timeout for this request.

Source

pub async fn send(self) -> Result<Response>

Sends the request and checks its HTTP status. A successful response’s body is read separately with Response::json, Response::bytes or a stream. Construction errors are returned before HTTP. Requests are never retried.

Trait Implementations§

Source§

impl<'a> Clone for Request<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Request<'_>

Omits query values, header values and the body, which can carry secrets.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for Request<'a>

§

impl<'a> !RefUnwindSafe for Request<'a>

§

impl<'a> !UnwindSafe for Request<'a>

§

impl<'a> Send for Request<'a>

§

impl<'a> Sync for Request<'a>

§

impl<'a> Unpin for Request<'a>

§

impl<'a> UnsafeUnpin for Request<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more