[][src]Struct yukikaze::client::request::Builder

pub struct Builder { /* fields omitted */ }

Http request builder.

Each method that may cause troubles shall panic.

Methods

impl Builder[src]

pub fn new(uri: Uri, method: Method) -> Self[src]

Starts process of creating request.

pub fn extensions(&self) -> &Extensions[src]

Retrieves reference to http extension map

pub fn extensions_mut(&mut self) -> &mut Extensions[src]

Retrieves mutable reference to http extension map

pub fn headers(&mut self) -> &mut HeaderMap[src]

Gets reference to headers.

pub fn if_some<T, F: FnOnce(T, Self) -> Self>(
    self,
    value: Option<T>,
    cb: F
) -> Self
[src]

Invokes closure with value and Self as arguments, if value contains something

pub fn set_header<K: IntoHeaderName, V>(self, key: K, value: V) -> Self where
    HeaderValue: TryFrom<V>, 
[src]

Sets new header to request.

If header exists, it replaces it.

Panics

  • On attempt to set invalid header value.

pub fn set_header_if_none<K: IntoHeaderName, V>(self, key: K, value: V) -> Self where
    HeaderValue: TryFrom<V>, 
[src]

Sets new header to request, only if it wasn't set previously.

Panics

  • On attempt to set invalid header value.

pub fn set_etag<E: EtagMode>(self, etag: &EntityTag, _: E) -> Self[src]

Sets ETag value into corresponding header.

If it is set, then value is appended to existing header as per standard after semicolon.

pub fn set_date<E: DateMode>(self, date: HttpDate, _: E) -> Self[src]

Sets HttpDate value into corresponding header.

Sets cookie jar to request.

If jar already exists, the cookies from jar are appended.

Adds cookie.

pub fn content_len(self, len: u64) -> Self[src]

Sets Content-Length header.

It replaces previous one, if there was any.

pub fn accept_encoding(self, encoding: ContentEncoding) -> Self[src]

Sets Accept-Encoding header.

Replaces previous value, if any.

pub fn content_disposition(self, disp: &ContentDisposition) -> Self[src]

Sets Content-Disposition header.

Replaces previous value, if any.

pub fn basic_auth<U: Display, P: Display>(
    self,
    username: U,
    password: Option<P>
) -> Self
[src]

Adds basic authentication header.

pub fn bearer_auth(self, token: &str) -> Self[src]

Adds bearer authentication header.

Generally tokens already contain only valid symbols for header. So the function doesn't encode it using base64.

pub fn query<Q: Serialize>(self, query: &Q) -> Self[src]

Sets request's query by overwriting existing one, if any.

Panics

  • If unable to encode data.
  • If URI creation fails

pub fn upgrade<U: Upgrade>(self, _: U, options: U::Options) -> Request[src]

Prepares upgrade for the request.

Existing mechanisms:

pub fn body<B: Into<Bytes>>(self, body: Option<B>) -> Request[src]

Creates request with specified body.

Adds Content-Length if not specified by user. Following RFC, adds zero length only for PUT and POST requests

pub fn form<F: Serialize>(self, body: &F) -> Result<Request, Error>[src]

Creates request with Form payload.

pub fn json<J: Serialize>(self, body: &J) -> Result<Request>[src]

Creates request with JSON payload.

pub fn multipart(self, body: Form) -> Request[src]

Creates request with multipart body.

pub fn empty(self) -> Request[src]

Creates request with no body.

Explicitly sets Content-Length to 0, if necessary

Auto Trait Implementations

impl Sync for Builder

impl Send for Builder

impl Unpin for Builder

impl !UnwindSafe for Builder

impl !RefUnwindSafe for Builder

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self