remove phantom

This commit is contained in:
Aiden McClelland
2021-04-12 20:56:24 -06:00
parent b9676c591a
commit 22ea1bf7b1
2 changed files with 4 additions and 10 deletions

View File

@@ -22,7 +22,7 @@ pub fn build(args: RpcServerArgs) -> TokenStream {
{
let ctx = #ctx;
let status_fn = #status_fn;
let (builder, ctx_phantom) = rpc_toolkit::rpc_server_helpers::make_builder(&ctx);
let builder = rpc_toolkit::rpc_server_helpers::make_builder(&ctx);
let make_svc = rpc_toolkit::hyper::service::make_service_fn(move |_| {
let ctx = ctx.clone();
async move {
@@ -36,7 +36,7 @@ pub fn build(args: RpcServerArgs) -> TokenStream {
Ok(rpc_req) => Ok((
rpc_req.id,
#command(
rpc_toolkit::rpc_server_helpers::bind_type(ctx_phantom, ctx),
ctx,
rpc_toolkit::yajrc::RpcMethod::as_str(&rpc_req.method),
rpc_req.params,
)

View File

@@ -1,5 +1,3 @@
use std::marker::PhantomData;
use hyper::body::Buf;
use hyper::server::conn::AddrIncoming;
use hyper::server::{Builder, Server};
@@ -20,18 +18,14 @@ lazy_static! {
serde_json::to_vec(&RpcResponse::<AnyRpcMethod<'static>>::from(yajrc::INTERNAL_ERROR)).unwrap();
}
pub fn make_builder<Ctx: Context>(ctx: &Ctx) -> (Builder<AddrIncoming>, PhantomData<Ctx>) {
pub fn make_builder<Ctx: Context>(ctx: &Ctx) -> Builder<AddrIncoming> {
let addr = match ctx.host() {
Host::Ipv4(ip) => (ip, ctx.port()).into(),
Host::Ipv6(ip) => (ip, ctx.port()).into(),
Host::Domain(localhost) if localhost == "localhost" => ([127, 0, 0, 1], ctx.port()).into(),
_ => ([0, 0, 0, 0], ctx.port()).into(),
};
(Server::bind(&addr), PhantomData)
}
pub fn bind_type<T>(_phantom: PhantomData<T>, actual: T) -> T {
actual
Server::bind(&addr)
}
pub async fn make_request<Params: for<'de> Deserialize<'de> + 'static>(