cometbft_proto/prost/
cometbft.services.version.v1.rs

1/// GetVersionRequest is the request for the ABCI version.
2#[allow(clippy::derive_partial_eq_without_eq)]
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct GetVersionRequest {}
5/// GetVersionResponse contains the ABCI application version info.
6#[allow(clippy::derive_partial_eq_without_eq)]
7#[derive(Clone, PartialEq, ::prost::Message)]
8pub struct GetVersionResponse {
9    /// The semantic version of the node software.
10    #[prost(string, tag = "1")]
11    pub node: ::prost::alloc::string::String,
12    /// The version of ABCI used by the node.
13    #[prost(string, tag = "2")]
14    pub abci: ::prost::alloc::string::String,
15    /// The version of the P2P protocol.
16    #[prost(uint64, tag = "3")]
17    pub p2p: u64,
18    /// The version of the block protocol.
19    #[prost(uint64, tag = "4")]
20    pub block: u64,
21}
22/// Generated server implementations.
23#[cfg(feature = "grpc-server")]
24pub mod version_service_server {
25    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
26    use tonic::codegen::*;
27    /// Generated trait containing gRPC methods that should be implemented for use with VersionServiceServer.
28    #[async_trait]
29    pub trait VersionService: Send + Sync + 'static {
30        /// GetVersion retrieves version information about the node and the protocols
31        /// it implements.
32        async fn get_version(
33            &self,
34            request: tonic::Request<super::GetVersionRequest>,
35        ) -> std::result::Result<
36            tonic::Response<super::GetVersionResponse>,
37            tonic::Status,
38        >;
39    }
40    /// VersionService simply provides version information about the node and the
41    /// protocols it uses.
42    ///
43    /// The intention with this service is to offer a stable interface through which
44    /// clients can access version information. This means that the version of the
45    /// service should be kept stable at v1, with GetVersionResponse evolving only
46    /// in non-breaking ways.
47    #[derive(Debug)]
48    pub struct VersionServiceServer<T: VersionService> {
49        inner: _Inner<T>,
50        accept_compression_encodings: EnabledCompressionEncodings,
51        send_compression_encodings: EnabledCompressionEncodings,
52        max_decoding_message_size: Option<usize>,
53        max_encoding_message_size: Option<usize>,
54    }
55    struct _Inner<T>(Arc<T>);
56    impl<T: VersionService> VersionServiceServer<T> {
57        pub fn new(inner: T) -> Self {
58            Self::from_arc(Arc::new(inner))
59        }
60        pub fn from_arc(inner: Arc<T>) -> Self {
61            let inner = _Inner(inner);
62            Self {
63                inner,
64                accept_compression_encodings: Default::default(),
65                send_compression_encodings: Default::default(),
66                max_decoding_message_size: None,
67                max_encoding_message_size: None,
68            }
69        }
70        pub fn with_interceptor<F>(
71            inner: T,
72            interceptor: F,
73        ) -> InterceptedService<Self, F>
74        where
75            F: tonic::service::Interceptor,
76        {
77            InterceptedService::new(Self::new(inner), interceptor)
78        }
79        /// Enable decompressing requests with the given encoding.
80        #[must_use]
81        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
82            self.accept_compression_encodings.enable(encoding);
83            self
84        }
85        /// Compress responses with the given encoding, if the client supports it.
86        #[must_use]
87        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
88            self.send_compression_encodings.enable(encoding);
89            self
90        }
91        /// Limits the maximum size of a decoded message.
92        ///
93        /// Default: `4MB`
94        #[must_use]
95        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
96            self.max_decoding_message_size = Some(limit);
97            self
98        }
99        /// Limits the maximum size of an encoded message.
100        ///
101        /// Default: `usize::MAX`
102        #[must_use]
103        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
104            self.max_encoding_message_size = Some(limit);
105            self
106        }
107    }
108    impl<T, B> tonic::codegen::Service<http::Request<B>> for VersionServiceServer<T>
109    where
110        T: VersionService,
111        B: Body + Send + 'static,
112        B::Error: Into<StdError> + Send + 'static,
113    {
114        type Response = http::Response<tonic::body::BoxBody>;
115        type Error = std::convert::Infallible;
116        type Future = BoxFuture<Self::Response, Self::Error>;
117        fn poll_ready(
118            &mut self,
119            _cx: &mut Context<'_>,
120        ) -> Poll<std::result::Result<(), Self::Error>> {
121            Poll::Ready(Ok(()))
122        }
123        fn call(&mut self, req: http::Request<B>) -> Self::Future {
124            let inner = self.inner.clone();
125            match req.uri().path() {
126                "/cometbft.services.version.v1.VersionService/GetVersion" => {
127                    #[allow(non_camel_case_types)]
128                    struct GetVersionSvc<T: VersionService>(pub Arc<T>);
129                    impl<
130                        T: VersionService,
131                    > tonic::server::UnaryService<super::GetVersionRequest>
132                    for GetVersionSvc<T> {
133                        type Response = super::GetVersionResponse;
134                        type Future = BoxFuture<
135                            tonic::Response<Self::Response>,
136                            tonic::Status,
137                        >;
138                        fn call(
139                            &mut self,
140                            request: tonic::Request<super::GetVersionRequest>,
141                        ) -> Self::Future {
142                            let inner = Arc::clone(&self.0);
143                            let fut = async move {
144                                <T as VersionService>::get_version(&inner, request).await
145                            };
146                            Box::pin(fut)
147                        }
148                    }
149                    let accept_compression_encodings = self.accept_compression_encodings;
150                    let send_compression_encodings = self.send_compression_encodings;
151                    let max_decoding_message_size = self.max_decoding_message_size;
152                    let max_encoding_message_size = self.max_encoding_message_size;
153                    let inner = self.inner.clone();
154                    let fut = async move {
155                        let inner = inner.0;
156                        let method = GetVersionSvc(inner);
157                        let codec = tonic::codec::ProstCodec::default();
158                        let mut grpc = tonic::server::Grpc::new(codec)
159                            .apply_compression_config(
160                                accept_compression_encodings,
161                                send_compression_encodings,
162                            )
163                            .apply_max_message_size_config(
164                                max_decoding_message_size,
165                                max_encoding_message_size,
166                            );
167                        let res = grpc.unary(method, req).await;
168                        Ok(res)
169                    };
170                    Box::pin(fut)
171                }
172                _ => {
173                    Box::pin(async move {
174                        Ok(
175                            http::Response::builder()
176                                .status(200)
177                                .header("grpc-status", "12")
178                                .header("content-type", "application/grpc")
179                                .body(empty_body())
180                                .unwrap(),
181                        )
182                    })
183                }
184            }
185        }
186    }
187    impl<T: VersionService> Clone for VersionServiceServer<T> {
188        fn clone(&self) -> Self {
189            let inner = self.inner.clone();
190            Self {
191                inner,
192                accept_compression_encodings: self.accept_compression_encodings,
193                send_compression_encodings: self.send_compression_encodings,
194                max_decoding_message_size: self.max_decoding_message_size,
195                max_encoding_message_size: self.max_encoding_message_size,
196            }
197        }
198    }
199    impl<T: VersionService> Clone for _Inner<T> {
200        fn clone(&self) -> Self {
201            Self(Arc::clone(&self.0))
202        }
203    }
204    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
205        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
206            write!(f, "{:?}", self.0)
207        }
208    }
209    impl<T: VersionService> tonic::server::NamedService for VersionServiceServer<T> {
210        const NAME: &'static str = "cometbft.services.version.v1.VersionService";
211    }
212}