#![allow(dead_code, unused_variables)]
type Response = String;
type Url = &'static str;
type Method = String;
#[maybe_async::maybe_async]
trait InnerClient {
async fn request(method: Method, url: Url, data: String) -> Response;
#[inline]
async fn post(url: Url, data: String) -> Response {
Self::request(String::from("post"), url, data).await
}
#[inline]
async fn delete(url: Url, data: String) -> Response {
Self::request(String::from("delete"), url, data).await
}
}
pub struct ServiceClient;
#[maybe_async::sync_impl]
impl InnerClient for ServiceClient {
fn request(method: Method, url: Url, data: String) -> Response {
String::from("pretend we have a response")
}
}
#[maybe_async::async_impl]
impl InnerClient for ServiceClient {
async fn request(method: Method, url: Url, data: String) -> Response {
String::from("pretend we have a response")
}
}
impl ServiceClient {
#[maybe_async::maybe_async]
async fn create_bucket(name: String) -> Response {
Self::post("http://correct_url4create", String::from("my_bucket")).await
}
#[maybe_async::maybe_async]
async fn delete_bucket(name: String) -> Response {
Self::delete("http://correct_url4delete", String::from("my_bucket")).await
}
}
#[maybe_async::sync_impl]
fn main() {
let _ = ServiceClient::create_bucket("bucket".to_owned());
}
#[maybe_async::async_impl]
#[tokio::main]
async fn main() {
let _ = ServiceClient::create_bucket("bucket".to_owned()).await;
}