api_binding 0.1.2

A library to create API binding libraries, inspired by the Gitlab bindings
Documentation
use async_trait::async_trait;
use http::Uri;
use url::Url;

use crate::{ApiError, AsyncClient, Client};

pub fn url_to_http_uri(url: Url) -> Uri {
    url.as_str()
        .parse::<Uri>()
        .expect("failed to parse url::Url as http::Uri")
}

pub trait Query<T, C>
where
    C: Client,
{
    fn query(&self, client: &C) -> Result<T, ApiError<C::Error>>;
}

#[async_trait]
pub trait AsyncQuery<T, C>
where
    C: AsyncClient,
{
    async fn query_async(&self, client: &C) -> Result<T, ApiError<C::Error>>;
}