RequestBuilder

Struct RequestBuilder 

Source
pub struct RequestBuilder<'a, T = ()> { /* private fields */ }
Expand description

Generic request builder. Used to construct custom requests towards CDF.

Implementations§

Source§

impl<'a> RequestBuilder<'a, ()>

Source

pub fn post(client: &'a ApiClient, url: impl IntoUrl) -> RequestBuilder<'a, ()>

Create a POST request to url.

§Arguments
  • client - API Client
  • url - URL to send request to.
Source

pub fn get(client: &'a ApiClient, url: impl IntoUrl) -> RequestBuilder<'a, ()>

Create a GET request to url.

§Arguments
  • client - API Client
  • url - URL to send request to.
Source

pub fn delete( client: &'a ApiClient, url: impl IntoUrl, ) -> RequestBuilder<'a, ()>

Create a DELETE request to url.

§Arguments
  • client - API Client
  • url - URL to send request to.
Source

pub fn put(client: &'a ApiClient, url: impl IntoUrl) -> RequestBuilder<'a, ()>

Create a PUT request to url.

§Arguments
  • client - API Client
  • url - URL to send request to.
Source§

impl<'a, T> RequestBuilder<'a, T>

Source

pub fn header<K, V>(self, key: K, value: V) -> Self

Add a header to the request.

§Arguments
  • key - Header key
  • value - Header value
Source

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

Add a query to the request.

Source

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

Add a JSON body to the request. This sets CONTENT_TYPE.

Source

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

Add a body to the request. You will typically want to set CONTENT_TYPE yourself.

Source

pub fn protobuf<B: Message>(self, body: &B) -> Self

Add a protobuf message as body to the request. This sets CONTENT_TYPE

Source

pub fn omit_auth_headers(self) -> Self

Omit authentication headers in the request.

This should be set before calling untrusted URLs.

Source

pub fn with_inner<R: FnOnce(RequestBuilder) -> RequestBuilder>( self, m: R, ) -> Self

Modify the inner request builder.

Source§

impl<'a> RequestBuilder<'a, ()>

Source

pub fn accept_json<T: DeserializeOwned>( self, ) -> RequestBuilder<'a, JsonResponseHandler<T>>

Expect the response for a successful request to be T encoded as JSON.

Source

pub fn accept_protobuf<T: Message + Default + Send + Sync>( self, ) -> RequestBuilder<'a, ProtoResponseHandler<T>>

Expect the response for a successful request to be T encoded as protobuf.

Source

pub fn accept_nothing(self) -> RequestBuilder<'a, NoResponseHandler>

Ignore the response for a successful request.

Source

pub fn accept_raw(self) -> RequestBuilder<'a, RawResponseHandler>

Simply return the raw payload on a successful request.

Source

pub fn accept<T: ResponseHandler>(self, handler: T) -> RequestBuilder<'a, T>

Set the response handler T.

Source§

impl<T: ResponseHandler> RequestBuilder<'_, T>

Source

pub async fn send(self) -> Result<T::Output>

Send the request. This sets a few core headers, and converts any errors into crate::Error

Auto Trait Implementations§

§

impl<'a, T = ()> !Freeze for RequestBuilder<'a, T>

§

impl<'a, T = ()> !RefUnwindSafe for RequestBuilder<'a, T>

§

impl<'a, T> Send for RequestBuilder<'a, T>
where T: Send,

§

impl<'a, T> Sync for RequestBuilder<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for RequestBuilder<'a, T>
where T: Unpin,

§

impl<'a, T = ()> !UnwindSafe for RequestBuilder<'a, T>

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> 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> IntoPatchItem<UpdateSet<T>> for T

Source§

fn patch(self, _options: &UpsertOptions) -> Option<UpdateSet<T>>

Convert self into a patch, optionally ignoring null values.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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