Skip to main content

RequestBuilder

Struct RequestBuilder 

Source
pub struct RequestBuilder<'a, E> { /* private fields */ }
Expand description

Builds one HTTP request. Obtained from Cx::request; finished with send.

A builder rather than more arguments on http(): it lets later additions (timeouts, query params) arrive as new links in the chain instead of bumping the arity of every existing call site.

Implementations§

Source§

impl<'a, E> RequestBuilder<'a, E>

Source

pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self

Add a request header. Order is preserved and names may repeat.

No #[must_use] here: it would be redundant with (and, per clippy’s double_must_use, a warning against) the one already on RequestBuilder itself, which covers every chained call returning Self.

Source

pub fn bearer(self, token: impl AsRef<str>) -> Self

Sugar for header("Authorization", format!("Bearer {token}")).

Source

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

Set the request body.

Source

pub fn send(self, then: impl FnOnce(HttpOutcome) -> E + Send + 'static)

Dispatch the request. then(outcome) produces the typed event delivered back to update once the shell replies.

Auto Trait Implementations§

§

impl<'a, E> !RefUnwindSafe for RequestBuilder<'a, E>

§

impl<'a, E> !Sync for RequestBuilder<'a, E>

§

impl<'a, E> !UnwindSafe for RequestBuilder<'a, E>

§

impl<'a, E> Freeze for RequestBuilder<'a, E>
where &'a mut Cx<E>: Freeze,

§

impl<'a, E> Send for RequestBuilder<'a, E>
where &'a mut Cx<E>: Send,

§

impl<'a, E> Unpin for RequestBuilder<'a, E>
where &'a mut Cx<E>: Unpin,

§

impl<'a, E> UnsafeUnpin for RequestBuilder<'a, E>
where &'a mut Cx<E>: UnsafeUnpin,

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, 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> Same for T

Source§

type Output = T

Should always be Self
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.