use std::any::TypeId;
use crate::tina::grpc::ApiGrpcService;
#[derive(Clone)]
pub(crate) struct GrpcServiceServer<S: ApiGrpcService> {
pub(crate) service: S,
pub(crate) methods_no_auth: Vec<TypeId>,
pub(crate) methods_auto_transaction: Vec<TypeId>,
}
impl<S: ApiGrpcService> GrpcServiceServer<S> {
pub fn new(service: S) -> Self {
Self {
service,
methods_no_auth: Vec::new(),
methods_auto_transaction: Vec::new(),
}
}
#[allow(unused_variables)]
pub fn with_no_auth<F, Args, R>(mut self, f: F) -> Self
where
F: Fn(Args) -> R + 'static,
{
self.methods_no_auth.push(TypeId::of::<F>());
self
}
#[allow(unused_variables)]
pub fn with_auto_transaction<F, Args, R>(mut self, f: F) -> Self
where
F: Fn(Args) -> R + 'static,
{
self.methods_auto_transaction.push(TypeId::of::<F>());
self
}
}