#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ShardInfo {
#[prost(uint32, tag = "1")]
pub shard_id: u32,
#[prost(uint32, tag = "2")]
pub epoch: u32,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetAccountRequest {
#[prost(bytes = "bytes", tag = "1")]
pub address: ::prost::bytes::Bytes,
#[prost(message, optional, tag = "2")]
pub shard: ::core::option::Option<ShardInfo>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetAccountsBatchRequest {
#[prost(bytes = "bytes", repeated, tag = "1")]
pub addresses: ::prost::alloc::vec::Vec<::prost::bytes::Bytes>,
#[prost(message, optional, tag = "2")]
pub shard: ::core::option::Option<ShardInfo>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetAccountResponse {
#[prost(bytes = "bytes", tag = "1")]
pub address: ::prost::bytes::Bytes,
#[prost(message, optional, tag = "2")]
pub account: ::core::option::Option<super::proto::UserAccountData>,
#[prost(bool, tag = "3")]
pub found: bool,
#[prost(string, tag = "4")]
pub error: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct NonceResponse {
#[prost(bytes = "bytes", tag = "1")]
pub address: ::prost::bytes::Bytes,
#[prost(uint64, tag = "2")]
pub nonce: u64,
#[prost(bool, tag = "3")]
pub found: bool,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct BalanceResponse {
#[prost(bytes = "bytes", tag = "1")]
pub address: ::prost::bytes::Bytes,
#[prost(bytes = "bytes", tag = "2")]
pub balance: ::prost::bytes::Bytes,
#[prost(bool, tag = "3")]
pub found: bool,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetStorageRequest {
#[prost(bytes = "bytes", tag = "1")]
pub address: ::prost::bytes::Bytes,
#[prost(message, optional, tag = "2")]
pub shard: ::core::option::Option<ShardInfo>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetStorageValueRequest {
#[prost(bytes = "bytes", tag = "1")]
pub address: ::prost::bytes::Bytes,
#[prost(bytes = "bytes", tag = "2")]
pub key: ::prost::bytes::Bytes,
#[prost(message, optional, tag = "3")]
pub shard: ::core::option::Option<ShardInfo>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StorageValueResponse {
#[prost(bytes = "bytes", tag = "1")]
pub key: ::prost::bytes::Bytes,
#[prost(bytes = "bytes", tag = "2")]
pub value: ::prost::bytes::Bytes,
#[prost(bool, tag = "3")]
pub found: bool,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct SearchRequest {
#[prost(bytes = "bytes", tag = "1")]
pub address: ::prost::bytes::Bytes,
#[prost(bytes = "bytes", tag = "2")]
pub prefix: ::prost::bytes::Bytes,
#[prost(uint32, tag = "3")]
pub limit: u32,
#[prost(message, optional, tag = "4")]
pub shard: ::core::option::Option<ShardInfo>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StorageEntry {
#[prost(bytes = "bytes", tag = "1")]
pub key: ::prost::bytes::Bytes,
#[prost(bytes = "bytes", tag = "2")]
pub value: ::prost::bytes::Bytes,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetTokensRequest {
#[prost(bytes = "bytes", tag = "1")]
pub address: ::prost::bytes::Bytes,
#[prost(message, optional, tag = "2")]
pub shard: ::core::option::Option<ShardInfo>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetTokenBalanceRequest {
#[prost(bytes = "bytes", tag = "1")]
pub address: ::prost::bytes::Bytes,
#[prost(bytes = "bytes", tag = "2")]
pub token_id: ::prost::bytes::Bytes,
#[prost(uint64, tag = "3")]
pub nonce: u64,
#[prost(message, optional, tag = "4")]
pub shard: ::core::option::Option<ShardInfo>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct TokenBalance {
#[prost(bytes = "bytes", tag = "1")]
pub token_id: ::prost::bytes::Bytes,
#[prost(uint64, tag = "2")]
pub nonce: u64,
#[prost(bytes = "bytes", tag = "3")]
pub balance: ::prost::bytes::Bytes,
#[prost(message, optional, tag = "4")]
pub token_data: ::core::option::Option<
super::proto_built_in_functions::EsDigitalToken,
>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct TokenBalanceResponse {
#[prost(message, optional, tag = "1")]
pub token: ::core::option::Option<TokenBalance>,
#[prost(bool, tag = "2")]
pub found: bool,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GetNftDataRequest {
#[prost(bytes = "bytes", tag = "1")]
pub token_id: ::prost::bytes::Bytes,
#[prost(uint64, tag = "2")]
pub nonce: u64,
#[prost(message, optional, tag = "3")]
pub shard: ::core::option::Option<ShardInfo>,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct NftDataResponse {
#[prost(message, optional, tag = "1")]
pub metadata: ::core::option::Option<super::proto_built_in_functions::MetaData>,
#[prost(bytes = "bytes", tag = "2")]
pub balance: ::prost::bytes::Bytes,
#[prost(bool, tag = "3")]
pub found: bool,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct HealthCheckRequest {
#[prost(string, tag = "1")]
pub service: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct HealthCheckResponse {
#[prost(enumeration = "health_check_response::ServingStatus", tag = "1")]
pub status: i32,
#[prost(string, tag = "2")]
pub message: ::prost::alloc::string::String,
}
pub mod health_check_response {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum ServingStatus {
Unknown = 0,
Serving = 1,
NotServing = 2,
}
impl ServingStatus {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unknown => "UNKNOWN",
Self::Serving => "SERVING",
Self::NotServing => "NOT_SERVING",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNKNOWN" => Some(Self::Unknown),
"SERVING" => Some(Self::Serving),
"NOT_SERVING" => Some(Self::NotServing),
_ => None,
}
}
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StatsRequest {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StatsResponse {
#[prost(uint64, tag = "1")]
pub cache_hits: u64,
#[prost(uint64, tag = "2")]
pub cache_misses: u64,
#[prost(uint64, tag = "3")]
pub cache_size: u64,
#[prost(uint64, tag = "4")]
pub total_reads: u64,
#[prost(uint64, tag = "5")]
pub total_keys: u64,
#[prost(message, repeated, tag = "6")]
pub shards: ::prost::alloc::vec::Vec<ShardStats>,
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ShardStats {
#[prost(uint32, tag = "1")]
pub shard_id: u32,
#[prost(uint32, tag = "2")]
pub current_epoch: u32,
#[prost(uint64, tag = "3")]
pub accounts_count: u64,
#[prost(bool, tag = "4")]
pub available: bool,
}
pub mod account_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct AccountServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl AccountServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> AccountServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> AccountServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
AccountServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn get_account(
&mut self,
request: impl tonic::IntoRequest<super::GetAccountRequest>,
) -> std::result::Result<
tonic::Response<super::GetAccountResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.AccountService/GetAccount",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.AccountService", "GetAccount"));
self.inner.unary(req, path, codec).await
}
pub async fn get_accounts_batch(
&mut self,
request: impl tonic::IntoRequest<super::GetAccountsBatchRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::GetAccountResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.AccountService/GetAccountsBatch",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.AccountService", "GetAccountsBatch"));
self.inner.server_streaming(req, path, codec).await
}
pub async fn get_nonce(
&mut self,
request: impl tonic::IntoRequest<super::GetAccountRequest>,
) -> std::result::Result<tonic::Response<super::NonceResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.AccountService/GetNonce",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.AccountService", "GetNonce"));
self.inner.unary(req, path, codec).await
}
pub async fn get_balance(
&mut self,
request: impl tonic::IntoRequest<super::GetAccountRequest>,
) -> std::result::Result<
tonic::Response<super::BalanceResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.AccountService/GetBalance",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.AccountService", "GetBalance"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod account_service_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait AccountService: std::marker::Send + std::marker::Sync + 'static {
async fn get_account(
&self,
request: tonic::Request<super::GetAccountRequest>,
) -> std::result::Result<
tonic::Response<super::GetAccountResponse>,
tonic::Status,
>;
type GetAccountsBatchStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::GetAccountResponse, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn get_accounts_batch(
&self,
request: tonic::Request<super::GetAccountsBatchRequest>,
) -> std::result::Result<
tonic::Response<Self::GetAccountsBatchStream>,
tonic::Status,
>;
async fn get_nonce(
&self,
request: tonic::Request<super::GetAccountRequest>,
) -> std::result::Result<tonic::Response<super::NonceResponse>, tonic::Status>;
async fn get_balance(
&self,
request: tonic::Request<super::GetAccountRequest>,
) -> std::result::Result<tonic::Response<super::BalanceResponse>, tonic::Status>;
}
#[derive(Debug)]
pub struct AccountServiceServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> AccountServiceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for AccountServiceServer<T>
where
T: AccountService,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::Body>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/storage.AccountService/GetAccount" => {
#[allow(non_camel_case_types)]
struct GetAccountSvc<T: AccountService>(pub Arc<T>);
impl<
T: AccountService,
> tonic::server::UnaryService<super::GetAccountRequest>
for GetAccountSvc<T> {
type Response = super::GetAccountResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetAccountRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AccountService>::get_account(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetAccountSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/storage.AccountService/GetAccountsBatch" => {
#[allow(non_camel_case_types)]
struct GetAccountsBatchSvc<T: AccountService>(pub Arc<T>);
impl<
T: AccountService,
> tonic::server::ServerStreamingService<
super::GetAccountsBatchRequest,
> for GetAccountsBatchSvc<T> {
type Response = super::GetAccountResponse;
type ResponseStream = T::GetAccountsBatchStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetAccountsBatchRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AccountService>::get_accounts_batch(&inner, request)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetAccountsBatchSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/storage.AccountService/GetNonce" => {
#[allow(non_camel_case_types)]
struct GetNonceSvc<T: AccountService>(pub Arc<T>);
impl<
T: AccountService,
> tonic::server::UnaryService<super::GetAccountRequest>
for GetNonceSvc<T> {
type Response = super::NonceResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetAccountRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AccountService>::get_nonce(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetNonceSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/storage.AccountService/GetBalance" => {
#[allow(non_camel_case_types)]
struct GetBalanceSvc<T: AccountService>(pub Arc<T>);
impl<
T: AccountService,
> tonic::server::UnaryService<super::GetAccountRequest>
for GetBalanceSvc<T> {
type Response = super::BalanceResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetAccountRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as AccountService>::get_balance(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetBalanceSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(
tonic::body::Body::default(),
);
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
}
}
impl<T> Clone for AccountServiceServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "storage.AccountService";
impl<T> tonic::server::NamedService for AccountServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}
pub mod storage_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct StorageServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl StorageServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> StorageServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> StorageServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
StorageServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn get_all_storage(
&mut self,
request: impl tonic::IntoRequest<super::GetStorageRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::StorageEntry>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.StorageService/GetAllStorage",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.StorageService", "GetAllStorage"));
self.inner.server_streaming(req, path, codec).await
}
pub async fn get_storage_value(
&mut self,
request: impl tonic::IntoRequest<super::GetStorageValueRequest>,
) -> std::result::Result<
tonic::Response<super::StorageValueResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.StorageService/GetStorageValue",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.StorageService", "GetStorageValue"));
self.inner.unary(req, path, codec).await
}
pub async fn search_by_prefix(
&mut self,
request: impl tonic::IntoRequest<super::SearchRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::StorageEntry>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.StorageService/SearchByPrefix",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.StorageService", "SearchByPrefix"));
self.inner.server_streaming(req, path, codec).await
}
}
}
pub mod storage_service_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait StorageService: std::marker::Send + std::marker::Sync + 'static {
type GetAllStorageStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::StorageEntry, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn get_all_storage(
&self,
request: tonic::Request<super::GetStorageRequest>,
) -> std::result::Result<
tonic::Response<Self::GetAllStorageStream>,
tonic::Status,
>;
async fn get_storage_value(
&self,
request: tonic::Request<super::GetStorageValueRequest>,
) -> std::result::Result<
tonic::Response<super::StorageValueResponse>,
tonic::Status,
>;
type SearchByPrefixStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::StorageEntry, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn search_by_prefix(
&self,
request: tonic::Request<super::SearchRequest>,
) -> std::result::Result<
tonic::Response<Self::SearchByPrefixStream>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct StorageServiceServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> StorageServiceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for StorageServiceServer<T>
where
T: StorageService,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::Body>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/storage.StorageService/GetAllStorage" => {
#[allow(non_camel_case_types)]
struct GetAllStorageSvc<T: StorageService>(pub Arc<T>);
impl<
T: StorageService,
> tonic::server::ServerStreamingService<super::GetStorageRequest>
for GetAllStorageSvc<T> {
type Response = super::StorageEntry;
type ResponseStream = T::GetAllStorageStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetStorageRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as StorageService>::get_all_storage(&inner, request)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetAllStorageSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/storage.StorageService/GetStorageValue" => {
#[allow(non_camel_case_types)]
struct GetStorageValueSvc<T: StorageService>(pub Arc<T>);
impl<
T: StorageService,
> tonic::server::UnaryService<super::GetStorageValueRequest>
for GetStorageValueSvc<T> {
type Response = super::StorageValueResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetStorageValueRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as StorageService>::get_storage_value(&inner, request)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetStorageValueSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/storage.StorageService/SearchByPrefix" => {
#[allow(non_camel_case_types)]
struct SearchByPrefixSvc<T: StorageService>(pub Arc<T>);
impl<
T: StorageService,
> tonic::server::ServerStreamingService<super::SearchRequest>
for SearchByPrefixSvc<T> {
type Response = super::StorageEntry;
type ResponseStream = T::SearchByPrefixStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::SearchRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as StorageService>::search_by_prefix(&inner, request)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = SearchByPrefixSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(
tonic::body::Body::default(),
);
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
}
}
impl<T> Clone for StorageServiceServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "storage.StorageService";
impl<T> tonic::server::NamedService for StorageServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}
pub mod token_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct TokenServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl TokenServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> TokenServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> TokenServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
TokenServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn get_all_tokens(
&mut self,
request: impl tonic::IntoRequest<super::GetTokensRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::TokenBalance>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.TokenService/GetAllTokens",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.TokenService", "GetAllTokens"));
self.inner.server_streaming(req, path, codec).await
}
pub async fn get_token_balance(
&mut self,
request: impl tonic::IntoRequest<super::GetTokenBalanceRequest>,
) -> std::result::Result<
tonic::Response<super::TokenBalanceResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.TokenService/GetTokenBalance",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.TokenService", "GetTokenBalance"));
self.inner.unary(req, path, codec).await
}
pub async fn get_nft_data(
&mut self,
request: impl tonic::IntoRequest<super::GetNftDataRequest>,
) -> std::result::Result<
tonic::Response<super::NftDataResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.TokenService/GetNftData",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.TokenService", "GetNftData"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod token_service_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait TokenService: std::marker::Send + std::marker::Sync + 'static {
type GetAllTokensStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::TokenBalance, tonic::Status>,
>
+ std::marker::Send
+ 'static;
async fn get_all_tokens(
&self,
request: tonic::Request<super::GetTokensRequest>,
) -> std::result::Result<
tonic::Response<Self::GetAllTokensStream>,
tonic::Status,
>;
async fn get_token_balance(
&self,
request: tonic::Request<super::GetTokenBalanceRequest>,
) -> std::result::Result<
tonic::Response<super::TokenBalanceResponse>,
tonic::Status,
>;
async fn get_nft_data(
&self,
request: tonic::Request<super::GetNftDataRequest>,
) -> std::result::Result<tonic::Response<super::NftDataResponse>, tonic::Status>;
}
#[derive(Debug)]
pub struct TokenServiceServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> TokenServiceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for TokenServiceServer<T>
where
T: TokenService,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::Body>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/storage.TokenService/GetAllTokens" => {
#[allow(non_camel_case_types)]
struct GetAllTokensSvc<T: TokenService>(pub Arc<T>);
impl<
T: TokenService,
> tonic::server::ServerStreamingService<super::GetTokensRequest>
for GetAllTokensSvc<T> {
type Response = super::TokenBalance;
type ResponseStream = T::GetAllTokensStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetTokensRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TokenService>::get_all_tokens(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetAllTokensSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/storage.TokenService/GetTokenBalance" => {
#[allow(non_camel_case_types)]
struct GetTokenBalanceSvc<T: TokenService>(pub Arc<T>);
impl<
T: TokenService,
> tonic::server::UnaryService<super::GetTokenBalanceRequest>
for GetTokenBalanceSvc<T> {
type Response = super::TokenBalanceResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetTokenBalanceRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TokenService>::get_token_balance(&inner, request)
.await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetTokenBalanceSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/storage.TokenService/GetNftData" => {
#[allow(non_camel_case_types)]
struct GetNftDataSvc<T: TokenService>(pub Arc<T>);
impl<
T: TokenService,
> tonic::server::UnaryService<super::GetNftDataRequest>
for GetNftDataSvc<T> {
type Response = super::NftDataResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::GetNftDataRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as TokenService>::get_nft_data(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetNftDataSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(
tonic::body::Body::default(),
);
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
}
}
impl<T> Clone for TokenServiceServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "storage.TokenService";
impl<T> tonic::server::NamedService for TokenServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}
pub mod health_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct HealthServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl HealthServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> HealthServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> HealthServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
HealthServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn check(
&mut self,
request: impl tonic::IntoRequest<super::HealthCheckRequest>,
) -> std::result::Result<
tonic::Response<super::HealthCheckResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.HealthService/Check",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.HealthService", "Check"));
self.inner.unary(req, path, codec).await
}
pub async fn get_stats(
&mut self,
request: impl tonic::IntoRequest<super::StatsRequest>,
) -> std::result::Result<tonic::Response<super::StatsResponse>, tonic::Status> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/storage.HealthService/GetStats",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("storage.HealthService", "GetStats"));
self.inner.unary(req, path, codec).await
}
}
}
pub mod health_service_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
#[async_trait]
pub trait HealthService: std::marker::Send + std::marker::Sync + 'static {
async fn check(
&self,
request: tonic::Request<super::HealthCheckRequest>,
) -> std::result::Result<
tonic::Response<super::HealthCheckResponse>,
tonic::Status,
>;
async fn get_stats(
&self,
request: tonic::Request<super::StatsRequest>,
) -> std::result::Result<tonic::Response<super::StatsResponse>, tonic::Status>;
}
#[derive(Debug)]
pub struct HealthServiceServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> HealthServiceServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for HealthServiceServer<T>
where
T: HealthService,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::Body>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/storage.HealthService/Check" => {
#[allow(non_camel_case_types)]
struct CheckSvc<T: HealthService>(pub Arc<T>);
impl<
T: HealthService,
> tonic::server::UnaryService<super::HealthCheckRequest>
for CheckSvc<T> {
type Response = super::HealthCheckResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::HealthCheckRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as HealthService>::check(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = CheckSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/storage.HealthService/GetStats" => {
#[allow(non_camel_case_types)]
struct GetStatsSvc<T: HealthService>(pub Arc<T>);
impl<
T: HealthService,
> tonic::server::UnaryService<super::StatsRequest>
for GetStatsSvc<T> {
type Response = super::StatsResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::StatsRequest>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as HealthService>::get_stats(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = GetStatsSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(
tonic::body::Body::default(),
);
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
}
}
impl<T> Clone for HealthServiceServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
pub const SERVICE_NAME: &str = "storage.HealthService";
impl<T> tonic::server::NamedService for HealthServiceServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}