sui_rpc_api/proto/generated/
sui.rpc.alpha.rs

1// This file is @generated by prost-build.
2/// Request authenticated events for a stream starting from a checkpoint.
3#[non_exhaustive]
4#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
5pub struct ListAuthenticatedEventsRequest {
6    /// Required. Stream identifier (Sui address) of the event stream.
7    #[prost(string, optional, tag = "1")]
8    pub stream_id: ::core::option::Option<::prost::alloc::string::String>,
9    /// Inclusive start checkpoint. Must not yet be pruned. (default: 0)
10    #[prost(uint64, optional, tag = "2")]
11    pub start_checkpoint: ::core::option::Option<u64>,
12    /// Number of events to return per page (default: 1000, max: 1000)
13    #[prost(uint32, optional, tag = "3")]
14    pub page_size: ::core::option::Option<u32>,
15    /// Page token for pagination. Use the next_page_token from previous response.
16    #[prost(bytes = "vec", optional, tag = "4")]
17    pub page_token: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
18}
19/// Response containing events and metadata.
20#[non_exhaustive]
21#[derive(Clone, PartialEq, ::prost::Message)]
22pub struct ListAuthenticatedEventsResponse {
23    #[prost(message, repeated, tag = "1")]
24    pub events: ::prost::alloc::vec::Vec<AuthenticatedEvent>,
25    /// The highest indexed checkpoint.
26    #[prost(uint64, optional, tag = "2")]
27    pub highest_indexed_checkpoint: ::core::option::Option<u64>,
28    /// Token for fetching the next page of results. Contains event key index range. Empty if no more pages.
29    #[prost(bytes = "vec", optional, tag = "3")]
30    pub next_page_token: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
31}
32/// Single authenticated Move event entry.
33#[non_exhaustive]
34#[derive(Clone, PartialEq, ::prost::Message)]
35pub struct AuthenticatedEvent {
36    /// The checkpoint sequence number where this event was recorded.
37    #[prost(uint64, optional, tag = "1")]
38    pub checkpoint: ::core::option::Option<u64>,
39    /// Index of the transaction within the checkpoint where the event was emitted.
40    #[prost(uint32, optional, tag = "2")]
41    pub transaction_idx: ::core::option::Option<u32>,
42    /// Index of the event within the transaction's event list.
43    #[prost(uint32, optional, tag = "3")]
44    pub event_idx: ::core::option::Option<u32>,
45    /// The event payload.
46    #[prost(message, optional, tag = "4")]
47    pub event: ::core::option::Option<::sui_rpc::proto::sui::rpc::v2::Event>,
48    /// The stream identifier (owner address) for which this event is authenticated.
49    #[prost(string, optional, tag = "5")]
50    pub stream_id: ::core::option::Option<::prost::alloc::string::String>,
51}
52/// Generated client implementations.
53pub mod event_service_client {
54    #![allow(
55        unused_variables,
56        dead_code,
57        missing_docs,
58        clippy::wildcard_imports,
59        clippy::let_unit_value,
60    )]
61    use tonic::codegen::*;
62    use tonic::codegen::http::Uri;
63    /// EventService provides paginated access to authenticated events per stream.
64    #[derive(Debug, Clone)]
65    pub struct EventServiceClient<T> {
66        inner: tonic::client::Grpc<T>,
67    }
68    impl EventServiceClient<tonic::transport::Channel> {
69        /// Attempt to create a new client by connecting to a given endpoint.
70        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
71        where
72            D: TryInto<tonic::transport::Endpoint>,
73            D::Error: Into<StdError>,
74        {
75            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
76            Ok(Self::new(conn))
77        }
78    }
79    impl<T> EventServiceClient<T>
80    where
81        T: tonic::client::GrpcService<tonic::body::Body>,
82        T::Error: Into<StdError>,
83        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
84        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
85    {
86        pub fn new(inner: T) -> Self {
87            let inner = tonic::client::Grpc::new(inner);
88            Self { inner }
89        }
90        pub fn with_origin(inner: T, origin: Uri) -> Self {
91            let inner = tonic::client::Grpc::with_origin(inner, origin);
92            Self { inner }
93        }
94        pub fn with_interceptor<F>(
95            inner: T,
96            interceptor: F,
97        ) -> EventServiceClient<InterceptedService<T, F>>
98        where
99            F: tonic::service::Interceptor,
100            T::ResponseBody: Default,
101            T: tonic::codegen::Service<
102                http::Request<tonic::body::Body>,
103                Response = http::Response<
104                    <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
105                >,
106            >,
107            <T as tonic::codegen::Service<
108                http::Request<tonic::body::Body>,
109            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
110        {
111            EventServiceClient::new(InterceptedService::new(inner, interceptor))
112        }
113        /// Compress requests with the given encoding.
114        ///
115        /// This requires the server to support it otherwise it might respond with an
116        /// error.
117        #[must_use]
118        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
119            self.inner = self.inner.send_compressed(encoding);
120            self
121        }
122        /// Enable decompressing responses.
123        #[must_use]
124        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
125            self.inner = self.inner.accept_compressed(encoding);
126            self
127        }
128        /// Limits the maximum size of a decoded message.
129        ///
130        /// Default: `4MB`
131        #[must_use]
132        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
133            self.inner = self.inner.max_decoding_message_size(limit);
134            self
135        }
136        /// Limits the maximum size of an encoded message.
137        ///
138        /// Default: `usize::MAX`
139        #[must_use]
140        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
141            self.inner = self.inner.max_encoding_message_size(limit);
142            self
143        }
144        /// Returns authenticated events for a given event stream ID.
145        pub async fn list_authenticated_events(
146            &mut self,
147            request: impl tonic::IntoRequest<super::ListAuthenticatedEventsRequest>,
148        ) -> std::result::Result<
149            tonic::Response<super::ListAuthenticatedEventsResponse>,
150            tonic::Status,
151        > {
152            self.inner
153                .ready()
154                .await
155                .map_err(|e| {
156                    tonic::Status::unknown(
157                        format!("Service was not ready: {}", e.into()),
158                    )
159                })?;
160            let codec = tonic_prost::ProstCodec::default();
161            let path = http::uri::PathAndQuery::from_static(
162                "/sui.rpc.alpha.EventService/ListAuthenticatedEvents",
163            );
164            let mut req = request.into_request();
165            req.extensions_mut()
166                .insert(
167                    GrpcMethod::new(
168                        "sui.rpc.alpha.EventService",
169                        "ListAuthenticatedEvents",
170                    ),
171                );
172            self.inner.unary(req, path, codec).await
173        }
174    }
175}
176/// Generated server implementations.
177pub mod event_service_server {
178    #![allow(
179        unused_variables,
180        dead_code,
181        missing_docs,
182        clippy::wildcard_imports,
183        clippy::let_unit_value,
184    )]
185    use tonic::codegen::*;
186    /// Generated trait containing gRPC methods that should be implemented for use with EventServiceServer.
187    #[async_trait]
188    pub trait EventService: std::marker::Send + std::marker::Sync + 'static {
189        /// Returns authenticated events for a given event stream ID.
190        async fn list_authenticated_events(
191            &self,
192            request: tonic::Request<super::ListAuthenticatedEventsRequest>,
193        ) -> std::result::Result<
194            tonic::Response<super::ListAuthenticatedEventsResponse>,
195            tonic::Status,
196        >;
197    }
198    /// EventService provides paginated access to authenticated events per stream.
199    #[derive(Debug)]
200    pub struct EventServiceServer<T> {
201        inner: Arc<T>,
202        accept_compression_encodings: EnabledCompressionEncodings,
203        send_compression_encodings: EnabledCompressionEncodings,
204        max_decoding_message_size: Option<usize>,
205        max_encoding_message_size: Option<usize>,
206    }
207    impl<T> EventServiceServer<T> {
208        pub fn new(inner: T) -> Self {
209            Self::from_arc(Arc::new(inner))
210        }
211        pub fn from_arc(inner: Arc<T>) -> Self {
212            Self {
213                inner,
214                accept_compression_encodings: Default::default(),
215                send_compression_encodings: Default::default(),
216                max_decoding_message_size: None,
217                max_encoding_message_size: None,
218            }
219        }
220        pub fn with_interceptor<F>(
221            inner: T,
222            interceptor: F,
223        ) -> InterceptedService<Self, F>
224        where
225            F: tonic::service::Interceptor,
226        {
227            InterceptedService::new(Self::new(inner), interceptor)
228        }
229        /// Enable decompressing requests with the given encoding.
230        #[must_use]
231        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
232            self.accept_compression_encodings.enable(encoding);
233            self
234        }
235        /// Compress responses with the given encoding, if the client supports it.
236        #[must_use]
237        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
238            self.send_compression_encodings.enable(encoding);
239            self
240        }
241        /// Limits the maximum size of a decoded message.
242        ///
243        /// Default: `4MB`
244        #[must_use]
245        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
246            self.max_decoding_message_size = Some(limit);
247            self
248        }
249        /// Limits the maximum size of an encoded message.
250        ///
251        /// Default: `usize::MAX`
252        #[must_use]
253        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
254            self.max_encoding_message_size = Some(limit);
255            self
256        }
257    }
258    impl<T, B> tonic::codegen::Service<http::Request<B>> for EventServiceServer<T>
259    where
260        T: EventService,
261        B: Body + std::marker::Send + 'static,
262        B::Error: Into<StdError> + std::marker::Send + 'static,
263    {
264        type Response = http::Response<tonic::body::Body>;
265        type Error = std::convert::Infallible;
266        type Future = BoxFuture<Self::Response, Self::Error>;
267        fn poll_ready(
268            &mut self,
269            _cx: &mut Context<'_>,
270        ) -> Poll<std::result::Result<(), Self::Error>> {
271            Poll::Ready(Ok(()))
272        }
273        fn call(&mut self, req: http::Request<B>) -> Self::Future {
274            match req.uri().path() {
275                "/sui.rpc.alpha.EventService/ListAuthenticatedEvents" => {
276                    #[allow(non_camel_case_types)]
277                    struct ListAuthenticatedEventsSvc<T: EventService>(pub Arc<T>);
278                    impl<
279                        T: EventService,
280                    > tonic::server::UnaryService<super::ListAuthenticatedEventsRequest>
281                    for ListAuthenticatedEventsSvc<T> {
282                        type Response = super::ListAuthenticatedEventsResponse;
283                        type Future = BoxFuture<
284                            tonic::Response<Self::Response>,
285                            tonic::Status,
286                        >;
287                        fn call(
288                            &mut self,
289                            request: tonic::Request<
290                                super::ListAuthenticatedEventsRequest,
291                            >,
292                        ) -> Self::Future {
293                            let inner = Arc::clone(&self.0);
294                            let fut = async move {
295                                <T as EventService>::list_authenticated_events(
296                                        &inner,
297                                        request,
298                                    )
299                                    .await
300                            };
301                            Box::pin(fut)
302                        }
303                    }
304                    let accept_compression_encodings = self.accept_compression_encodings;
305                    let send_compression_encodings = self.send_compression_encodings;
306                    let max_decoding_message_size = self.max_decoding_message_size;
307                    let max_encoding_message_size = self.max_encoding_message_size;
308                    let inner = self.inner.clone();
309                    let fut = async move {
310                        let method = ListAuthenticatedEventsSvc(inner);
311                        let codec = tonic_prost::ProstCodec::default();
312                        let mut grpc = tonic::server::Grpc::new(codec)
313                            .apply_compression_config(
314                                accept_compression_encodings,
315                                send_compression_encodings,
316                            )
317                            .apply_max_message_size_config(
318                                max_decoding_message_size,
319                                max_encoding_message_size,
320                            );
321                        let res = grpc.unary(method, req).await;
322                        Ok(res)
323                    };
324                    Box::pin(fut)
325                }
326                _ => {
327                    Box::pin(async move {
328                        let mut response = http::Response::new(
329                            tonic::body::Body::default(),
330                        );
331                        let headers = response.headers_mut();
332                        headers
333                            .insert(
334                                tonic::Status::GRPC_STATUS,
335                                (tonic::Code::Unimplemented as i32).into(),
336                            );
337                        headers
338                            .insert(
339                                http::header::CONTENT_TYPE,
340                                tonic::metadata::GRPC_CONTENT_TYPE,
341                            );
342                        Ok(response)
343                    })
344                }
345            }
346        }
347    }
348    impl<T> Clone for EventServiceServer<T> {
349        fn clone(&self) -> Self {
350            let inner = self.inner.clone();
351            Self {
352                inner,
353                accept_compression_encodings: self.accept_compression_encodings,
354                send_compression_encodings: self.send_compression_encodings,
355                max_decoding_message_size: self.max_decoding_message_size,
356                max_encoding_message_size: self.max_encoding_message_size,
357            }
358        }
359    }
360    /// Generated gRPC service name
361    pub const SERVICE_NAME: &str = "sui.rpc.alpha.EventService";
362    impl<T> tonic::server::NamedService for EventServiceServer<T> {
363        const NAME: &'static str = SERVICE_NAME;
364    }
365}