mirror of
https://github.com/Start9Labs/rpc-toolkit.git
synced 2026-03-26 02:11:56 +00:00
remove phantom
This commit is contained in:
@@ -22,7 +22,7 @@ pub fn build(args: RpcServerArgs) -> TokenStream {
|
|||||||
{
|
{
|
||||||
let ctx = #ctx;
|
let ctx = #ctx;
|
||||||
let status_fn = #status_fn;
|
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 make_svc = rpc_toolkit::hyper::service::make_service_fn(move |_| {
|
||||||
let ctx = ctx.clone();
|
let ctx = ctx.clone();
|
||||||
async move {
|
async move {
|
||||||
@@ -36,7 +36,7 @@ pub fn build(args: RpcServerArgs) -> TokenStream {
|
|||||||
Ok(rpc_req) => Ok((
|
Ok(rpc_req) => Ok((
|
||||||
rpc_req.id,
|
rpc_req.id,
|
||||||
#command(
|
#command(
|
||||||
rpc_toolkit::rpc_server_helpers::bind_type(ctx_phantom, ctx),
|
ctx,
|
||||||
rpc_toolkit::yajrc::RpcMethod::as_str(&rpc_req.method),
|
rpc_toolkit::yajrc::RpcMethod::as_str(&rpc_req.method),
|
||||||
rpc_req.params,
|
rpc_req.params,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
use hyper::body::Buf;
|
use hyper::body::Buf;
|
||||||
use hyper::server::conn::AddrIncoming;
|
use hyper::server::conn::AddrIncoming;
|
||||||
use hyper::server::{Builder, Server};
|
use hyper::server::{Builder, Server};
|
||||||
@@ -20,18 +18,14 @@ lazy_static! {
|
|||||||
serde_json::to_vec(&RpcResponse::<AnyRpcMethod<'static>>::from(yajrc::INTERNAL_ERROR)).unwrap();
|
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() {
|
let addr = match ctx.host() {
|
||||||
Host::Ipv4(ip) => (ip, ctx.port()).into(),
|
Host::Ipv4(ip) => (ip, ctx.port()).into(),
|
||||||
Host::Ipv6(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(),
|
Host::Domain(localhost) if localhost == "localhost" => ([127, 0, 0, 1], ctx.port()).into(),
|
||||||
_ => ([0, 0, 0, 0], ctx.port()).into(),
|
_ => ([0, 0, 0, 0], ctx.port()).into(),
|
||||||
};
|
};
|
||||||
(Server::bind(&addr), PhantomData)
|
Server::bind(&addr)
|
||||||
}
|
|
||||||
|
|
||||||
pub fn bind_type<T>(_phantom: PhantomData<T>, actual: T) -> T {
|
|
||||||
actual
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn make_request<Params: for<'de> Deserialize<'de> + 'static>(
|
pub async fn make_request<Params: for<'de> Deserialize<'de> + 'static>(
|
||||||
|
|||||||
Reference in New Issue
Block a user