Struct Builder
struct Builder { ... }
An HTTP request builder
This type can be used to construct an instance or Request
through a builder-like pattern.
Implementations
impl Builder
fn new() -> BuilderCreates a new default instance of
Builderto construct aRequest.Examples
# use *; let req = new .method .body .unwrap;fn method<T>(self: Self, method: T) -> Builder where T: TryInto<Method>, <T as TryInto<Method>>::Error: Into<crate::Error>Set the HTTP method for this request.
By default this is
GET.Examples
# use *; let req = builder .method .body .unwrap;fn method_ref(self: &Self) -> Option<&Method>Get the HTTP Method for this request.
By default this is
GET. If builder has error, returns None.Examples
# use *; let mut req = builder; assert_eq!; req = req.method; assert_eq!;fn uri<T>(self: Self, uri: T) -> Builder where T: TryInto<Uri>, <T as TryInto<Uri>>::Error: Into<crate::Error>Set the URI for this request.
By default this is
/.Examples
# use *; let req = builder .uri .body .unwrap;fn uri_ref(self: &Self) -> Option<&Uri>Get the URI for this request
By default this is
/.Examples
# use *; let mut req = builder; assert_eq!; req = req.uri; assert_eq!;fn version(self: Self, version: Version) -> BuilderSet the HTTP version for this request.
By default this is HTTP/1.1
Examples
# use *; let req = builder .version .body .unwrap;fn version_ref(self: &Self) -> Option<&Version>Get the HTTP version for this request
By default this is HTTP/1.1.
Examples
# use *; let mut req = builder; assert_eq!; req = req.version; assert_eq!;fn header<K, V>(self: Self, key: K, value: V) -> Builder where K: TryInto<HeaderName>, <K as TryInto<HeaderName>>::Error: Into<crate::Error>, V: TryInto<HeaderValue>, <V as TryInto<HeaderValue>>::Error: Into<crate::Error>Appends a header to this request builder.
This function will append the provided key/value as a header to the internal
HeaderMapbeing constructed. Essentially this is equivalent to callingHeaderMap::append.Examples
# use *; # use HeaderValue; let req = builder .header .header .body .unwrap;fn headers_ref(self: &Self) -> Option<&HeaderMap<HeaderValue>>Get header on this request builder. when builder has error returns None
Example
# use Request; let req = builder .header .header; let headers = req.headers_ref.unwrap; assert_eq!; assert_eq!;fn headers_mut(self: &mut Self) -> Option<&mut HeaderMap<HeaderValue>>Get headers on this request builder.
When builder has error returns None.
Example
# use ; let mut req = builder; let headers = req.headers_ref.unwrap; assert_eq!; assert_eq!;fn extension<T>(self: Self, extension: T) -> Builder where T: Clone + Any + Send + Sync + 'staticAdds an extension to this builder
Examples
# use *; let req = builder .extension .body .unwrap; assert_eq!;fn extensions_ref(self: &Self) -> Option<&Extensions>Get a reference to the extensions for this request builder.
If the builder has an error, this returns
None.Example
# use Request; let req = builder.extension.extension; let extensions = req.extensions_ref.unwrap; assert_eq!; assert_eq!;fn extensions_mut(self: &mut Self) -> Option<&mut Extensions>Get a mutable reference to the extensions for this request builder.
If the builder has an error, this returns
None.Example
# use Request; let mut req = builder.extension; let mut extensions = req.extensions_mut.unwrap; assert_eq!; extensions.insert; assert_eq!;fn body<T>(self: Self, body: T) -> Result<Request<T>>"Consumes" this builder, using the provided
bodyto return a constructedRequest.Errors
This function may return an error if any previously configured argument failed to parse or get converted to the internal representation. For example if an invalid
headwas specified viaheader("Foo", "Bar\r\n")the error will be returned when this function is called rather than whenheaderwas called.Examples
# use *; let request = builder .body .unwrap;
impl Debug for Builder
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
impl Default for Builder
fn default() -> Builder
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
impl<T> Any for Builder
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Builder
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Builder
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for Builder
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for Builder
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Builder
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Builder
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>