Request

Struct Request 

Source
pub struct Request;

Implementations§

Source§

impl Request

请求封装类

Source

pub async fn head( url: &str, query: Option<&HashMap<String, String>>, headers: Option<&HashMap<String, String>>, ) -> Result<Response, Response>

send Head request

§Examples
use rust_qcos::request::Request;
use std::collections::HashMap;
async {
let mut headers = HashMap::new();
headers.insert("x-test-header".to_string(), "test-header".to_string());
Request::head("https://www.baiduc.com", None, Some(&headers)).await;
};
Source

pub async fn get( url: &str, query: Option<&HashMap<String, String>>, headers: Option<&HashMap<String, String>>, ) -> Result<Response, Response>

send get request

§Examples
use rust_qcos::request::Request;
use std::collections::HashMap;
async {
let mut headers = HashMap::new();
headers.insert("x-test-header".to_string(), "test-header".to_string());
Request::get("https://www.baiduc.com", None, Some(&headers)).await;
};
Source

pub async fn post<T: Into<Body>>( url: &str, query: Option<&HashMap<String, String>>, headers: Option<&HashMap<String, String>>, form: Option<&HashMap<&str, Value>>, json: Option<&HashMap<&str, Value>>, body_data: Option<T>, ) -> Result<Response, Response>

send post request

§Examples
use reqwest::Body;
use rust_qcos::request::Request;
use std::collections::HashMap;
use serde_json::json;
async {
let mut form = HashMap::new();
form.insert("hello", json!(1i16));
form.insert("hello1", json!("world"));
let mut json = HashMap::new();
json.insert("hello", json!(1i64));
json.insert("hello_json", json!("world"));
json.insert("data", json!(vec![1u8, 2u8, 3u8] as Vec<u8>));
let resp = Request::post(
    "https://www.baidu.com",
    None,
    None,
    Some(&form),
    Some(&json),
    None as Option<Body>,
).await;
};
Source

pub async fn put<T: Into<Body>>( url: &str, query: Option<&HashMap<String, String>>, headers: Option<&HashMap<String, String>>, form: Option<&HashMap<&str, Value>>, json: Option<&HashMap<&str, Value>>, body_data: Option<T>, ) -> Result<Response, Response>

send put request

Source

pub async fn delete( url: &str, query: Option<&HashMap<String, String>>, headers: Option<&HashMap<String, String>>, form: Option<&HashMap<&str, Value>>, json: Option<&HashMap<&str, Value>>, ) -> Result<Response, Response>

send delete request

Auto Trait Implementations§

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> 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 = 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<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
Source§

impl<T> ErasedDestructor for T
where T: 'static,