odata_client 0.1.0

Client for accessing OData APIs
Documentation
use reqwest::{Request, Response};
use std::{future::Future, pin::Pin};

/// Used to send HTTP requests for OData operations. A custom implementation may be used in order to
/// e.g. add authentication headers before sending the request.
pub trait ODataHttpClient {
    type Response: Future<Output = Result<Response, reqwest::Error>>;

    /// Takes an HTTP request prepared for a specific OData operation, makes any necessary
    /// modifications specific to this client, and performs the HTTP request.
    fn execute_request(&self, request: Request) -> Self::Response;
}

impl ODataHttpClient for reqwest::Client {
    type Response = Pin<Box<dyn Future<Output = Result<Response, reqwest::Error>>>>;

    fn execute_request(&self, request: Request) -> Self::Response {
        Box::pin(self.execute(request))
    }
}