rpc-api 0.1.0

A typed rpc library to be used by wasm and other targets
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use async_trait::async_trait;

use crate::rpc::Transport;

pub struct HttpReqwestTransport {
    pub url: String,
}

#[async_trait(?Send)]
impl Transport for HttpReqwestTransport {
    async fn send(&self, payload: &str) -> String {
        let client = reqwest::Client::new();
        let string = &self.url;
        let x = payload.to_string();
        let res = client.post(string).body(x).send().await.unwrap();
        res.text().await.unwrap()
    }
}