Skip to main content

HttpRequest

Struct HttpRequest 

Source
pub struct HttpRequest { /* private fields */ }
Expand description

HTTP request data and execution state.

Holds everything needed to issue one outgoing request: method, URL, headers (single-value HashMap<String, String> — see hyperlane-standards §8.1), body, and per-request config (timeout, redirect policy, proxy, decode, etc.).

HttpRequest is constructed either via crate::RequestBuilder or directly from its public fields, then sent via HttpRequest::send (sync) or HttpRequest::send_async.

Implementations§

Source§

impl HttpRequest

Inherent implementation of HttpRequest.

Source

pub fn send(&mut self) -> Result<HttpResponse, RequestError>

Send the HTTP request synchronously, returning the parsed response.

§Returns
  • Result<HttpResponse, RequestError> - The parsed HTTP response, or a RequestError on failure.
Source

pub async fn send_async(&mut self) -> Result<HttpResponse, RequestError>

Send the HTTP request asynchronously, returning the parsed response.

§Returns
  • Result<HttpResponse, RequestError> - The parsed HTTP response, or a RequestError on failure.
Source§

impl HttpRequest

Inherent implementation of HttpRequest.

Source

pub fn get<T>(url: T) -> Self
where T: Into<String>,

Create a GET request for url.

§Arguments
  • T - The request URL, converted into an owned String.
§Returns
  • Self - A GET HttpRequest targeting url.
Source

pub fn post<T>(url: T) -> Self
where T: Into<String>,

Create a POST request for url.

§Arguments
  • T - The request URL, converted into an owned String.
§Returns
  • Self - A POST HttpRequest targeting url.
Source

pub fn set_method(&mut self, method: Method) -> &mut Self

Builder-style: set method.

§Arguments
  • Method - The HTTP method to use for the request.
§Returns
  • &mut Self - The request itself, for chaining.
Source

pub fn set_url<T>(&mut self, url: T) -> &mut Self
where T: Into<String>,

Builder-style: set URL.

§Arguments
  • T - The request URL, converted into an owned String.
§Returns
  • &mut Self - The request itself, for chaining.
Source

pub fn set_header<K, V>(&mut self, key: K, value: V) -> &mut Self
where K: AsRef<str>, V: AsRef<str>,

Builder-style: set a single header (case-insensitive on read; the last value wins for repeated keys).

§Arguments
  • K - The header name, normalised to lowercase.
  • V - The header value, stored as an owned String.
§Returns
  • &mut Self - The request itself, for chaining.
Source

pub fn remove_header<K>(&mut self, key: K) -> &mut Self
where K: AsRef<str>,

Remove a header by key.

§Arguments
  • K - The header name to remove, matched case-insensitively.
§Returns
  • &mut Self - The request itself, for chaining.
Source

pub fn clear_headers(&mut self) -> &mut Self

Clear all headers.

§Returns
  • &mut Self - The request itself, for chaining.
Source

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

Set body (raw bytes).

§Arguments
  • Body - The body payload to send.
§Returns
  • &mut Self - The request itself, for chaining.
Source

pub fn set_config(&mut self, config: RequestConfig) -> &mut Self

Set a single config field by mutating the embedded RequestConfig.

§Arguments
  • RequestConfig - The configuration replacing the current one.
§Returns
  • &mut Self - The request itself, for chaining.
Source§

impl HttpRequest

Source

pub fn get_method(&self) -> Method

Source

pub fn get_url(&self) -> &String

Source

pub fn get_headers(&self) -> &HashMap<String, String>

Source

pub fn get_body(&self) -> &Body

Source

pub fn get_config(&self) -> &RequestConfig

Source

pub fn get_tmp(&self) -> &Tmp

Source§

impl HttpRequest

Source

pub fn get_mut_headers(&mut self) -> &mut HashMap<String, String>

Source

pub fn get_mut_config(&mut self) -> &mut RequestConfig

Source

pub fn get_mut_tmp(&mut self) -> &mut Tmp

Trait Implementations§

Source§

impl Clone for HttpRequest

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 HttpRequest

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for HttpRequest

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for HttpRequest

§

impl Freeze for HttpRequest

§

impl Move for HttpRequest

§

impl RefUnwindSafe for HttpRequest

§

impl Send for HttpRequest
where RawVecInner: Send, RawTable<(String, String)>: Send, RawTable<(String, ())>: Send, &'static [u8]: Send,

§

impl Sync for HttpRequest
where RawVecInner: Sync, RawTable<(String, String)>: Sync, RawTable<(String, ())>: Sync,

§

impl Unpin for HttpRequest
where *const u8 is !null: Unpin, &'static [u8]: Unpin,

§

impl UnsafeUnpin for HttpRequest

§

impl UnwindSafe for HttpRequest
where RawVecInner: UnwindSafe, HashMap<String, String>: UnwindSafe, NonNull<u8>: UnwindSafe, &'static [u8]: UnwindSafe,

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> AnySend for T
where T: Any + Send,

Source§

impl<T> AnySendClone for T
where T: Any + Send + Clone,

Source§

impl<T> AnySendSync for T
where T: Any + Send + Sync,

Source§

impl<T> AnySendSyncClone for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> AnySync for T
where T: Any + Sync,

Source§

impl<T> AnySyncClone for T
where T: Any + Sync + Clone,

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