Skip to main content

DocHttpClient

Trait DocHttpClient 

Source
pub trait DocHttpClient:
    Send
    + Sync
    + Debug {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn usage_snippet(&self) -> &str;
    fn execute<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        url: &'life2 str,
        headers: &'life3 HashMap<String, String>,
        body: Option<&'life4 str>,
        parameters: &'life5 HashMap<String, String>,
    ) -> Pin<Box<dyn Future<Output = Result<DocHttpResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             'life5: 'async_trait;
}
Expand description

A named HTTP client usable from the documentation test hook.

Each client describes itself with name, description, and usage_snippet, and can execute an arbitrary request.

Required Methods§

Source

fn name(&self) -> &str

Display the name of the client (for example, "Classic HTTP Client").

Source

fn description(&self) -> &str

Short description of the client’s behavior.

Source

fn usage_snippet(&self) -> &str

Short snippet illustrating typical usage.

Source

fn execute<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, method: &'life1 str, url: &'life2 str, headers: &'life3 HashMap<String, String>, body: Option<&'life4 str>, parameters: &'life5 HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<DocHttpResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Executes one HTTP request and returns the response.

method is the HTTP method, url the absolute URL, headers the headers to send, body the optional request body, and parameters extra query parameters to append. Returns an error if the request cannot be built or sent.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§