polyester/gen/connect/chain.zipper.v1.rs
1// @generated by connectrpc-codegen. DO NOT EDIT.
2
3///Shorthand for `OwnedView<GetDepositWithdrawConfigRequestView<'static>>`.
4pub type OwnedGetDepositWithdrawConfigRequestView = ::buffa::view::OwnedView<
5 crate::proto::chain::zipper::v1::__buffa::view::GetDepositWithdrawConfigRequestView<
6 'static,
7 >,
8>;
9///Shorthand for `OwnedView<GetDepositWithdrawConfigResponseView<'static>>`.
10pub type OwnedGetDepositWithdrawConfigResponseView = ::buffa::view::OwnedView<
11 crate::proto::chain::zipper::v1::__buffa::view::GetDepositWithdrawConfigResponseView<
12 'static,
13 >,
14>;
15impl ::connectrpc::Encodable<
16 crate::proto::chain::zipper::v1::GetDepositWithdrawConfigResponse,
17>
18for crate::proto::chain::zipper::v1::__buffa::view::GetDepositWithdrawConfigResponseView<
19 '_,
20> {
21 fn encode(
22 &self,
23 codec: ::connectrpc::CodecFormat,
24 ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> {
25 ::connectrpc::__codegen::encode_view_body(self, codec)
26 }
27}
28impl ::connectrpc::Encodable<
29 crate::proto::chain::zipper::v1::GetDepositWithdrawConfigResponse,
30>
31for ::buffa::view::OwnedView<
32 crate::proto::chain::zipper::v1::__buffa::view::GetDepositWithdrawConfigResponseView<
33 'static,
34 >,
35> {
36 fn encode(
37 &self,
38 codec: ::connectrpc::CodecFormat,
39 ) -> ::std::result::Result<::buffa::bytes::Bytes, ::connectrpc::ConnectError> {
40 ::connectrpc::__codegen::encode_view_body(self.reborrow(), codec)
41 }
42}
43/// Full service name for this service.
44pub const ZIPPER_SERVICE_SERVICE_NAME: &str = "chain.zipper.v1.ZipperService";
45/// Static [`Spec`](::connectrpc::Spec) for the server-side `GetDepositWithdrawConfig` RPC.
46///
47/// The dispatcher surfaces this on
48/// [`RequestContext::spec`](::connectrpc::RequestContext::spec).
49pub const ZIPPER_SERVICE_GET_DEPOSIT_WITHDRAW_CONFIG_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server(
50 "/chain.zipper.v1.ZipperService/GetDepositWithdrawConfig",
51 ::connectrpc::StreamType::Unary,
52 )
53 .with_idempotency_level(::connectrpc::IdempotencyLevel::Unknown);
54/// ZipperService exposes deposit and withdraw chain configuration.
55///
56/// # Implementing handlers
57///
58/// Implement methods with plain `async fn`; the returned future satisfies
59/// the `Send` bound automatically.
60///
61/// **Unary and server-streaming requests** arrive as
62/// [`ServiceRequest<'_, Req>`](::connectrpc::ServiceRequest): a zero-copy
63/// view of the request plus its body, valid for the duration of the call.
64/// Fields are read directly (`request.name` is a `&str` into the decoded
65/// buffer) and the borrow may be held across `.await` points. Anything
66/// that must outlive the call — `tokio::spawn`, channels, server state,
67/// or data captured by a returned response stream — takes owned data:
68/// call `request.to_owned_message()` (or copy the specific fields)
69/// first.
70///
71/// **Client-streaming and bidi requests** arrive as
72/// [`InboundStream<Req>`](::connectrpc::InboundStream) — a
73/// `ServiceStream` of [`StreamMessage`](::connectrpc::StreamMessage)s.
74/// Each item owns its decoded buffer and is `Send + 'static`, so items
75/// can be buffered or moved into spawned tasks; read fields zero-copy
76/// through the generated accessor methods (`item.name()`) or `.view()`,
77/// convert with `.to_owned_message()`, or yield an item back unchanged —
78/// `StreamMessage<M>` implements `Encodable<M>`.
79///
80/// Request types resolved through `extern_path` (e.g. well-known types
81/// from another crate) use the same wrappers; the crate that owns the
82/// type must be generated with buffa ≥ 0.8.0 and views enabled so the
83/// backing `HasMessageView` impl exists.
84///
85/// The `impl Encodable<Out>` return bound accepts the owned `Out`, the
86/// generated `OutView<'_>` / `OwnedOutView`,
87/// [`MaybeBorrowed`](::connectrpc::MaybeBorrowed), or
88/// [`PreEncoded`](::connectrpc::PreEncoded) for handlers that encode a
89/// non-`'static` view internally and pass the bytes across the handler
90/// boundary. View bodies are not emitted for output types mapped via
91/// `extern_path` (the impl would be an orphan); return owned for
92/// WKT/extern outputs.
93///
94/// Server-streaming and bidi-streaming methods return
95/// `ServiceStream<impl Encodable<Out> + Send + use<Self>>`. The
96/// `use<Self>` precise-capturing clause excludes `&self`'s lifetime and
97/// the request's lifetime (unary methods use `use<'a, Self>` and may
98/// borrow from `&self`), so stream items must be `'static` and cannot
99/// borrow from the request. To stream view-encoded data, encode each
100/// item inside the stream body and yield
101/// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming
102/// example` doc.
103#[allow(clippy::type_complexity)]
104pub trait ZipperService: Send + Sync + 'static {
105 /// Retrieve the supported chains and unified assets used by deposit/withdraw UI flows.
106 ///
107 /// `'a` lets the response body borrow from `&self` (e.g. server-resident state).
108 ///
109 /// `request` is borrowed from the request body and is valid for the
110 /// duration of the call; message fields are read directly on it
111 /// (zero-copy). The response cannot borrow from `request` — use
112 /// `.to_owned_message()` (or copy the specific fields) for anything
113 /// returned, stored, or moved into `tokio::spawn`.
114 fn get_deposit_withdraw_config<'a>(
115 &'a self,
116 ctx: ::connectrpc::RequestContext,
117 request: ::connectrpc::ServiceRequest<
118 '_,
119 crate::proto::chain::zipper::v1::GetDepositWithdrawConfigRequest,
120 >,
121 ) -> impl ::std::future::Future<
122 Output = ::connectrpc::ServiceResult<
123 impl ::connectrpc::Encodable<
124 crate::proto::chain::zipper::v1::GetDepositWithdrawConfigResponse,
125 > + Send + use<'a, Self>,
126 >,
127 > + Send;
128}
129/// Extension trait for registering a service implementation with a Router.
130///
131/// This trait is automatically implemented for all types that implement the service trait.
132/// Prefer [`Router::add_service`](::connectrpc::Router::add_service) for
133/// top-down registration; `register` remains available for compatibility
134/// and cases where the service-first call shape is more convenient.
135///
136/// # Example
137///
138/// ```rust,ignore
139/// use std::sync::Arc;
140///
141/// let service = Arc::new(MyServiceImpl);
142/// let router = service.register(Router::new());
143/// ```
144pub trait ZipperServiceExt: ZipperService {
145 /// Register this service implementation with a Router.
146 ///
147 /// Takes ownership of the `Arc<Self>` and returns a new Router with
148 /// this service's methods registered.
149 fn register(
150 self: ::std::sync::Arc<Self>,
151 router: ::connectrpc::Router,
152 ) -> ::connectrpc::Router;
153}
154impl<S: ZipperService> ZipperServiceExt for S {
155 fn register(
156 self: ::std::sync::Arc<Self>,
157 router: ::connectrpc::Router,
158 ) -> ::connectrpc::Router {
159 router
160 .route_view(
161 ZIPPER_SERVICE_SERVICE_NAME,
162 "GetDepositWithdrawConfig",
163 {
164 let svc = ::std::sync::Arc::clone(&self);
165 ::connectrpc::view_handler_fn(move |
166 ctx,
167 req: ::buffa::view::OwnedView<
168 crate::proto::chain::zipper::v1::__buffa::view::GetDepositWithdrawConfigRequestView<
169 'static,
170 >,
171 >,
172 format|
173 {
174 let svc = ::std::sync::Arc::clone(&svc);
175 async move {
176 let sreq = ::connectrpc::ServiceRequest::<
177 crate::proto::chain::zipper::v1::GetDepositWithdrawConfigRequest,
178 >::from_parts(req.reborrow(), req.bytes());
179 svc.get_deposit_withdraw_config(ctx, sreq)
180 .await?
181 .encode::<
182 crate::proto::chain::zipper::v1::GetDepositWithdrawConfigResponse,
183 >(format)
184 }
185 })
186 },
187 )
188 .with_spec(ZIPPER_SERVICE_GET_DEPOSIT_WITHDRAW_CONFIG_SPEC)
189 }
190}
191/// Type-inference marker used by [`Router::add_service`](::connectrpc::Router::add_service).
192#[doc(hidden)]
193pub struct ZipperServiceRegisterMarker;
194impl<S: ZipperService> ::connectrpc::ServiceRegister<ZipperServiceRegisterMarker>
195for ::std::sync::Arc<S> {
196 fn register_service(self, router: ::connectrpc::Router) -> ::connectrpc::Router {
197 <S as ZipperServiceExt>::register(self, router)
198 }
199}
200/// Monomorphic dispatcher for `ZipperService`.
201///
202/// Unlike `.register(Router)` which type-erases each method into an `Arc<dyn ErasedHandler>` stored in a `HashMap`, this struct dispatches via a compile-time `match` on method name: no vtable, no hash lookup.
203///
204/// # Example
205///
206/// ```rust,ignore
207/// use connectrpc::ConnectRpcService;
208///
209/// let server = ZipperServiceServer::new(MyImpl);
210/// let service = ConnectRpcService::new(server);
211/// // hand `service` to axum/hyper as a fallback_service
212/// ```
213pub struct ZipperServiceServer<T> {
214 inner: ::std::sync::Arc<T>,
215}
216impl<T: ZipperService> ZipperServiceServer<T> {
217 /// Wrap a service implementation in a monomorphic dispatcher.
218 pub fn new(service: T) -> Self {
219 Self {
220 inner: ::std::sync::Arc::new(service),
221 }
222 }
223 /// Wrap an already-`Arc`'d service implementation.
224 pub fn from_arc(inner: ::std::sync::Arc<T>) -> Self {
225 Self { inner }
226 }
227}
228impl<T> Clone for ZipperServiceServer<T> {
229 fn clone(&self) -> Self {
230 Self {
231 inner: ::std::sync::Arc::clone(&self.inner),
232 }
233 }
234}
235impl<T: ZipperService> ::connectrpc::Dispatcher for ZipperServiceServer<T> {
236 #[inline]
237 fn lookup(
238 &self,
239 path: &str,
240 ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> {
241 let method = path.strip_prefix("chain.zipper.v1.ZipperService/")?;
242 match method {
243 "GetDepositWithdrawConfig" => {
244 Some(
245 ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false)
246 .with_spec(ZIPPER_SERVICE_GET_DEPOSIT_WITHDRAW_CONFIG_SPEC),
247 )
248 }
249 _ => None,
250 }
251 }
252 fn call_unary(
253 &self,
254 path: &str,
255 ctx: ::connectrpc::RequestContext,
256 request: ::connectrpc::Payload,
257 format: ::connectrpc::CodecFormat,
258 ) -> ::connectrpc::dispatcher::codegen::UnaryResult {
259 let Some(method) = path.strip_prefix("chain.zipper.v1.ZipperService/") else {
260 return ::connectrpc::dispatcher::codegen::unimplemented_unary(path);
261 };
262 let _ = (&ctx, &request, &format);
263 match method {
264 "GetDepositWithdrawConfig" => {
265 let svc = ::std::sync::Arc::clone(&self.inner);
266 Box::pin(async move {
267 let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::<
268 crate::proto::chain::zipper::v1::GetDepositWithdrawConfigRequest,
269 >(request.encoded()?, format)?;
270 let req: crate::proto::chain::zipper::v1::__buffa::view::GetDepositWithdrawConfigRequestView<
271 '_,
272 > = ::connectrpc::dispatcher::codegen::decode_borrowed_request_view(
273 &body,
274 )?;
275 let req = ::connectrpc::ServiceRequest::<
276 crate::proto::chain::zipper::v1::GetDepositWithdrawConfigRequest,
277 >::from_parts(&req, &body);
278 svc.get_deposit_withdraw_config(ctx, req)
279 .await?
280 .encode::<
281 crate::proto::chain::zipper::v1::GetDepositWithdrawConfigResponse,
282 >(format)
283 })
284 }
285 _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path),
286 }
287 }
288 fn call_server_streaming(
289 &self,
290 path: &str,
291 ctx: ::connectrpc::RequestContext,
292 request: ::buffa::bytes::Bytes,
293 format: ::connectrpc::CodecFormat,
294 ) -> ::connectrpc::dispatcher::codegen::StreamingResult {
295 let Some(method) = path.strip_prefix("chain.zipper.v1.ZipperService/") else {
296 return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path);
297 };
298 let _ = (&ctx, &request, &format);
299 match method {
300 _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path),
301 }
302 }
303 fn call_client_streaming(
304 &self,
305 path: &str,
306 ctx: ::connectrpc::RequestContext,
307 requests: ::connectrpc::dispatcher::codegen::RequestStream,
308 format: ::connectrpc::CodecFormat,
309 ) -> ::connectrpc::dispatcher::codegen::UnaryResult {
310 let Some(method) = path.strip_prefix("chain.zipper.v1.ZipperService/") else {
311 return ::connectrpc::dispatcher::codegen::unimplemented_unary(path);
312 };
313 let _ = (&ctx, &requests, &format);
314 match method {
315 _ => ::connectrpc::dispatcher::codegen::unimplemented_unary(path),
316 }
317 }
318 fn call_bidi_streaming(
319 &self,
320 path: &str,
321 ctx: ::connectrpc::RequestContext,
322 requests: ::connectrpc::dispatcher::codegen::RequestStream,
323 format: ::connectrpc::CodecFormat,
324 ) -> ::connectrpc::dispatcher::codegen::StreamingResult {
325 let Some(method) = path.strip_prefix("chain.zipper.v1.ZipperService/") else {
326 return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path);
327 };
328 let _ = (&ctx, &requests, &format);
329 match method {
330 _ => ::connectrpc::dispatcher::codegen::unimplemented_streaming(path),
331 }
332 }
333}
334/// Client for this service.
335///
336/// Generic over `T: ClientTransport`. For **gRPC** (HTTP/2), use
337/// `Http2Connection` — it has honest `poll_ready` and composes with
338/// `tower::balance` for multi-connection load balancing. For **Connect
339/// over HTTP/1.1** (or unknown protocol), use `HttpClient`.
340///
341/// # Working with the response
342///
343/// Unary calls return [`UnaryResponse<OwnedView<FooView>>`](::connectrpc::client::UnaryResponse).
344/// [`view()`](::connectrpc::client::UnaryResponse::view) borrows the response
345/// message, so field access is zero-copy:
346///
347/// ```rust,ignore
348/// let resp = client.get_deposit_withdraw_config(request).await?;
349/// let name: &str = resp.view().name; // borrow into the response buffer
350/// ```
351///
352/// If you need the owned struct (e.g. to store or pass by value), use
353/// [`into_owned()`](::connectrpc::client::UnaryResponse::into_owned):
354///
355/// ```rust,ignore
356/// let owned = client.get_deposit_withdraw_config(request).await?.into_owned();
357/// ```
358///
359/// [`into_view()`](::connectrpc::client::UnaryResponse::into_view) keeps the
360/// zero-copy decoded body (an `OwnedView`) without copying; field access on it
361/// goes through `.reborrow()`. Streaming responses yield one
362/// [`StreamMessage`](::connectrpc::StreamMessage) per received message from
363/// `.message().await` — read fields zero-copy through the generated accessor
364/// methods (`msg.name()`) or `.view()`, or convert with `.to_owned_message()`.
365#[derive(Clone)]
366pub struct ZipperServiceClient<T> {
367 transport: T,
368 config: ::connectrpc::client::ClientConfig,
369}
370impl<T> ZipperServiceClient<T>
371where
372 T: ::connectrpc::client::ClientTransport,
373 <T::ResponseBody as ::connectrpc::http_body::Body>::Error: ::std::fmt::Display,
374{
375 /// Create a new client with the given transport and configuration.
376 pub fn new(transport: T, config: ::connectrpc::client::ClientConfig) -> Self {
377 Self { transport, config }
378 }
379 /// Get the client configuration.
380 pub fn config(&self) -> &::connectrpc::client::ClientConfig {
381 &self.config
382 }
383 /// Get a mutable reference to the client configuration.
384 pub fn config_mut(&mut self) -> &mut ::connectrpc::client::ClientConfig {
385 &mut self.config
386 }
387 /// Call the GetDepositWithdrawConfig RPC. Sends a request to /chain.zipper.v1.ZipperService/GetDepositWithdrawConfig.
388 pub async fn get_deposit_withdraw_config(
389 &self,
390 request: crate::proto::chain::zipper::v1::GetDepositWithdrawConfigRequest,
391 ) -> Result<
392 ::connectrpc::client::UnaryResponse<
393 ::buffa::view::OwnedView<
394 crate::proto::chain::zipper::v1::__buffa::view::GetDepositWithdrawConfigResponseView<
395 'static,
396 >,
397 >,
398 >,
399 ::connectrpc::ConnectError,
400 > {
401 self.get_deposit_withdraw_config_with_options(
402 request,
403 ::connectrpc::client::CallOptions::default(),
404 )
405 .await
406 }
407 /// Call the GetDepositWithdrawConfig RPC with explicit per-call options. Options override [`ClientConfig`](::connectrpc::client::ClientConfig) defaults.
408 pub async fn get_deposit_withdraw_config_with_options(
409 &self,
410 request: crate::proto::chain::zipper::v1::GetDepositWithdrawConfigRequest,
411 options: ::connectrpc::client::CallOptions,
412 ) -> Result<
413 ::connectrpc::client::UnaryResponse<
414 ::buffa::view::OwnedView<
415 crate::proto::chain::zipper::v1::__buffa::view::GetDepositWithdrawConfigResponseView<
416 'static,
417 >,
418 >,
419 >,
420 ::connectrpc::ConnectError,
421 > {
422 ::connectrpc::client::call_unary(
423 &self.transport,
424 &self.config,
425 ZIPPER_SERVICE_SERVICE_NAME,
426 "GetDepositWithdrawConfig",
427 request,
428 options,
429 )
430 .await
431 }
432}