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