pub mod offline;
pub mod online;
pub mod online_without_reflection;
mod types;
pub use types::*;
use crate::{grpc::client::GrpcClient, reflection::client::ReflectionClient};
use prost_reflect::DescriptorPool;
use std::fmt::Debug;
use tonic::transport::Channel;
#[derive(Clone, Debug)]
pub struct GrancClient<T> {
state: T,
}
impl<T> GrancClient<T> {
pub(crate) fn new(state: T) -> Self {
Self { state }
}
}
#[derive(Debug, Clone)]
pub struct Online<S = Channel> {
reflection_client: ReflectionClient<S>,
grpc_client: GrpcClient<S>,
}
#[derive(Debug, Clone)]
pub struct OnlineWithoutReflection<S = Channel> {
grpc_client: GrpcClient<S>,
pool: DescriptorPool,
}
impl<S> OnlineWithoutReflection<S> {
pub(crate) fn new(grpc_client: GrpcClient<S>, pool: DescriptorPool) -> Self {
Self { pool, grpc_client }
}
}
#[derive(Debug, Clone)]
pub struct Offline {
pool: DescriptorPool,
}
impl Offline {
pub(crate) fn new(pool: DescriptorPool) -> Self {
Self { pool }
}
}
pub trait OfflineReflectionState {
fn descriptor_pool(&self) -> &DescriptorPool;
}
impl OfflineReflectionState for Offline {
fn descriptor_pool(&self) -> &DescriptorPool {
&self.pool
}
}
impl<S> OfflineReflectionState for OnlineWithoutReflection<S> {
fn descriptor_pool(&self) -> &DescriptorPool {
&self.pool
}
}