#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ForwardingAccount {
#[prost(message, optional, tag = "1")]
pub base_account: ::core::option::Option<
super::super::super::cosmos::auth::v1beta1::BaseAccount,
>,
#[prost(string, tag = "2")]
pub channel: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub recipient: ::prost::alloc::string::String,
#[prost(int64, tag = "4")]
pub created_at: i64,
}
impl ::prost::Name for ForwardingAccount {
const NAME: &'static str = "ForwardingAccount";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ForwardingPubKey {
#[prost(bytes = "vec", tag = "1")]
pub key: ::prost::alloc::vec::Vec<u8>,
}
impl ::prost::Name for ForwardingPubKey {
const NAME: &'static str = "ForwardingPubKey";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenesisState {
#[prost(map = "string, uint64", tag = "1")]
pub num_of_accounts: ::std::collections::HashMap<
::prost::alloc::string::String,
u64,
>,
#[prost(map = "string, uint64", tag = "2")]
pub num_of_forwards: ::std::collections::HashMap<
::prost::alloc::string::String,
u64,
>,
#[prost(map = "string, string", tag = "3")]
pub total_forwarded: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::string::String,
>,
}
impl ::prost::Name for GenesisState {
const NAME: &'static str = "GenesisState";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegisterAccountData {
#[prost(string, tag = "1")]
pub recipient: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub channel: ::prost::alloc::string::String,
}
impl ::prost::Name for RegisterAccountData {
const NAME: &'static str = "RegisterAccountData";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegisterAccountMemo {
#[prost(message, optional, tag = "1")]
pub noble: ::core::option::Option<register_account_memo::RegisterAccountDataWrapper>,
}
pub mod register_account_memo {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RegisterAccountDataWrapper {
#[prost(message, optional, tag = "1")]
pub forwarding: ::core::option::Option<super::RegisterAccountData>,
}
impl ::prost::Name for RegisterAccountDataWrapper {
const NAME: &'static str = "RegisterAccountDataWrapper";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!(
"noble.forwarding.v1.RegisterAccountMemo.{}", Self::NAME
)
}
}
}
impl ::prost::Name for RegisterAccountMemo {
const NAME: &'static str = "RegisterAccountMemo";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryAddress {
#[prost(string, tag = "1")]
pub channel: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub recipient: ::prost::alloc::string::String,
}
impl ::prost::Name for QueryAddress {
const NAME: &'static str = "QueryAddress";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryAddressResponse {
#[prost(string, tag = "1")]
pub address: ::prost::alloc::string::String,
#[prost(bool, tag = "2")]
pub exists: bool,
}
impl ::prost::Name for QueryAddressResponse {
const NAME: &'static str = "QueryAddressResponse";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryStats {}
impl ::prost::Name for QueryStats {
const NAME: &'static str = "QueryStats";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryStatsResponse {
#[prost(map = "string, message", tag = "1")]
pub stats: ::std::collections::HashMap<::prost::alloc::string::String, Stats>,
}
impl ::prost::Name for QueryStatsResponse {
const NAME: &'static str = "QueryStatsResponse";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryStatsByChannel {
#[prost(string, tag = "1")]
pub channel: ::prost::alloc::string::String,
}
impl ::prost::Name for QueryStatsByChannel {
const NAME: &'static str = "QueryStatsByChannel";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryStatsByChannelResponse {
#[prost(uint64, tag = "1")]
pub num_of_accounts: u64,
#[prost(uint64, tag = "2")]
pub num_of_forwards: u64,
#[prost(message, repeated, tag = "3")]
pub total_forwarded: ::prost::alloc::vec::Vec<
super::super::super::cosmos::base::v1beta1::Coin,
>,
}
impl ::prost::Name for QueryStatsByChannelResponse {
const NAME: &'static str = "QueryStatsByChannelResponse";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Stats {
#[prost(string, tag = "1")]
pub chain_id: ::prost::alloc::string::String,
#[prost(uint64, tag = "2")]
pub num_of_accounts: u64,
#[prost(uint64, tag = "3")]
pub num_of_forwards: u64,
#[prost(message, repeated, tag = "4")]
pub total_forwarded: ::prost::alloc::vec::Vec<
super::super::super::cosmos::base::v1beta1::Coin,
>,
}
impl ::prost::Name for Stats {
const NAME: &'static str = "Stats";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[cfg(feature = "rpc")]
pub mod query_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct QueryClient<T> {
inner: tonic::client::Grpc<T>,
}
impl QueryClient<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> QueryClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + 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,
) -> QueryClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
QueryClient::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 address(
&mut self,
request: impl tonic::IntoRequest<super::QueryAddress>,
) -> std::result::Result<
tonic::Response<super::QueryAddressResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/noble.forwarding.v1.Query/Address",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("noble.forwarding.v1.Query", "Address"));
self.inner.unary(req, path, codec).await
}
pub async fn stats(
&mut self,
request: impl tonic::IntoRequest<super::QueryStats>,
) -> std::result::Result<
tonic::Response<super::QueryStatsResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/noble.forwarding.v1.Query/Stats",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("noble.forwarding.v1.Query", "Stats"));
self.inner.unary(req, path, codec).await
}
pub async fn stats_by_channel(
&mut self,
request: impl tonic::IntoRequest<super::QueryStatsByChannel>,
) -> std::result::Result<
tonic::Response<super::QueryStatsByChannelResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/noble.forwarding.v1.Query/StatsByChannel",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("noble.forwarding.v1.Query", "StatsByChannel"));
self.inner.unary(req, path, codec).await
}
}
}
#[cfg(feature = "rpc")]
pub mod query_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait Query: Send + Sync + 'static {
async fn address(
&self,
request: tonic::Request<super::QueryAddress>,
) -> std::result::Result<
tonic::Response<super::QueryAddressResponse>,
tonic::Status,
>;
async fn stats(
&self,
request: tonic::Request<super::QueryStats>,
) -> std::result::Result<
tonic::Response<super::QueryStatsResponse>,
tonic::Status,
>;
async fn stats_by_channel(
&self,
request: tonic::Request<super::QueryStatsByChannel>,
) -> std::result::Result<
tonic::Response<super::QueryStatsByChannelResponse>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct QueryServer<T: Query> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
struct _Inner<T>(Arc<T>);
impl<T: Query> QueryServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
let inner = _Inner(inner);
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 QueryServer<T>
where
T: Query,
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
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 {
let inner = self.inner.clone();
match req.uri().path() {
"/noble.forwarding.v1.Query/Address" => {
#[allow(non_camel_case_types)]
struct AddressSvc<T: Query>(pub Arc<T>);
impl<T: Query> tonic::server::UnaryService<super::QueryAddress>
for AddressSvc<T> {
type Response = super::QueryAddressResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::QueryAddress>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Query>::address(&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 inner = inner.0;
let method = AddressSvc(inner);
let codec = tonic::codec::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)
}
"/noble.forwarding.v1.Query/Stats" => {
#[allow(non_camel_case_types)]
struct StatsSvc<T: Query>(pub Arc<T>);
impl<T: Query> tonic::server::UnaryService<super::QueryStats>
for StatsSvc<T> {
type Response = super::QueryStatsResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::QueryStats>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Query>::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 inner = inner.0;
let method = StatsSvc(inner);
let codec = tonic::codec::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)
}
"/noble.forwarding.v1.Query/StatsByChannel" => {
#[allow(non_camel_case_types)]
struct StatsByChannelSvc<T: Query>(pub Arc<T>);
impl<
T: Query,
> tonic::server::UnaryService<super::QueryStatsByChannel>
for StatsByChannelSvc<T> {
type Response = super::QueryStatsByChannelResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::QueryStatsByChannel>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Query>::stats_by_channel(&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 inner = inner.0;
let method = StatsByChannelSvc(inner);
let codec = tonic::codec::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 {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: Query> Clone for QueryServer<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,
}
}
}
impl<T: Query> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(Arc::clone(&self.0))
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: Query> tonic::server::NamedService for QueryServer<T> {
const NAME: &'static str = "noble.forwarding.v1.Query";
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgRegisterAccount {
#[prost(string, tag = "1")]
pub signer: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub recipient: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub channel: ::prost::alloc::string::String,
}
impl ::prost::Name for MsgRegisterAccount {
const NAME: &'static str = "MsgRegisterAccount";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgRegisterAccountResponse {
#[prost(string, tag = "1")]
pub address: ::prost::alloc::string::String,
}
impl ::prost::Name for MsgRegisterAccountResponse {
const NAME: &'static str = "MsgRegisterAccountResponse";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgClearAccount {
#[prost(string, tag = "1")]
pub signer: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub address: ::prost::alloc::string::String,
}
impl ::prost::Name for MsgClearAccount {
const NAME: &'static str = "MsgClearAccount";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MsgClearAccountResponse {}
impl ::prost::Name for MsgClearAccountResponse {
const NAME: &'static str = "MsgClearAccountResponse";
const PACKAGE: &'static str = "noble.forwarding.v1";
fn full_name() -> ::prost::alloc::string::String {
::prost::alloc::format!("noble.forwarding.v1.{}", Self::NAME)
}
}
#[cfg(feature = "rpc")]
pub mod msg_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct MsgClient<T> {
inner: tonic::client::Grpc<T>,
}
impl MsgClient<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> MsgClient<T>
where
T: tonic::client::GrpcService<tonic::body::BoxBody>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + 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,
) -> MsgClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::BoxBody>,
>>::Error: Into<StdError> + Send + Sync,
{
MsgClient::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 register_account(
&mut self,
request: impl tonic::IntoRequest<super::MsgRegisterAccount>,
) -> std::result::Result<
tonic::Response<super::MsgRegisterAccountResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/noble.forwarding.v1.Msg/RegisterAccount",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("noble.forwarding.v1.Msg", "RegisterAccount"));
self.inner.unary(req, path, codec).await
}
pub async fn clear_account(
&mut self,
request: impl tonic::IntoRequest<super::MsgClearAccount>,
) -> std::result::Result<
tonic::Response<super::MsgClearAccountResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/noble.forwarding.v1.Msg/ClearAccount",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(GrpcMethod::new("noble.forwarding.v1.Msg", "ClearAccount"));
self.inner.unary(req, path, codec).await
}
}
}
#[cfg(feature = "rpc")]
pub mod msg_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
#[async_trait]
pub trait Msg: Send + Sync + 'static {
async fn register_account(
&self,
request: tonic::Request<super::MsgRegisterAccount>,
) -> std::result::Result<
tonic::Response<super::MsgRegisterAccountResponse>,
tonic::Status,
>;
async fn clear_account(
&self,
request: tonic::Request<super::MsgClearAccount>,
) -> std::result::Result<
tonic::Response<super::MsgClearAccountResponse>,
tonic::Status,
>;
}
#[derive(Debug)]
pub struct MsgServer<T: Msg> {
inner: _Inner<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
struct _Inner<T>(Arc<T>);
impl<T: Msg> MsgServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
let inner = _Inner(inner);
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 MsgServer<T>
where
T: Msg,
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
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 {
let inner = self.inner.clone();
match req.uri().path() {
"/noble.forwarding.v1.Msg/RegisterAccount" => {
#[allow(non_camel_case_types)]
struct RegisterAccountSvc<T: Msg>(pub Arc<T>);
impl<T: Msg> tonic::server::UnaryService<super::MsgRegisterAccount>
for RegisterAccountSvc<T> {
type Response = super::MsgRegisterAccountResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::MsgRegisterAccount>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Msg>::register_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 inner = inner.0;
let method = RegisterAccountSvc(inner);
let codec = tonic::codec::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)
}
"/noble.forwarding.v1.Msg/ClearAccount" => {
#[allow(non_camel_case_types)]
struct ClearAccountSvc<T: Msg>(pub Arc<T>);
impl<T: Msg> tonic::server::UnaryService<super::MsgClearAccount>
for ClearAccountSvc<T> {
type Response = super::MsgClearAccountResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::MsgClearAccount>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as Msg>::clear_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 inner = inner.0;
let method = ClearAccountSvc(inner);
let codec = tonic::codec::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 {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: Msg> Clone for MsgServer<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,
}
}
}
impl<T: Msg> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(Arc::clone(&self.0))
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
impl<T: Msg> tonic::server::NamedService for MsgServer<T> {
const NAME: &'static str = "noble.forwarding.v1.Msg";
}
}