tokio-thrift-codegen 0.1.0

code generation library of tokio-thrift
Documentation
#[allow(dead_code, non_snake_case, non_camel_case_types)]
#[derive(Clone)]
pub struct {{service.ident}}Server<T>
{
    inner: T,
}

impl <T: {{service.ident}}Service>{{service.ident}}Server<T>
{
    pub fn new(inner: T) -> Self
    {
        {{service.ident}}Server {
            inner: inner
        }
    }
}

impl <T> ::tokio_service::Service for {{service.ident}}Server<T>
    where T: {{service.ident}}Service
{
    type Request = {{service.ident}}ServiceMethodArgs;
    type Response = {{service.ident}}ServiceMethodReturn;
    type Error = ::std::io::Error;
    type Future = ::futures::future::BoxFuture<{{service.ident}}ServiceMethodReturn, ::std::io::Error>;


    fn call(&self, req: Self::Request) -> Self::Future {
        use futures::Future;
        use {{../namespace}}::{{service.ident}}ServiceMethodArgs::*;
        use {{../namespace}}::{{service.ident}}ServiceMethodReturn::*;
        match req {
            {{~#each service.methods as |method|}}
            A{{method.ident}}(_args)  => self.inner.{{method.ident}}(
                {{~#each method.args as |arg|}}
                _args.{{arg.ident}},
                {{~/each}}
            ).then(|r| ::futures::finished(R{{method.ident}}(r))).boxed(),
            {{~/each}}
        }
    }
}