Files
boc/aamos-ledger-rust/target/debug/deps/libtower_service-5cde83e30b362864.rlib
T

92 lines
24 KiB
Plaintext
Raw Normal View History

!<arch>
/ 0 0 0 0 8 `
// 76 `
tower_service-5cde83e30b362864.tower_service.e7b573d5bb113974-cgu.0.rcgu.o/
lib.rmeta/ 0 0 0 644 23664 `
ELF·ðZ@@GNUÀrust
¨X#rustc 1.96.0 (ac68faa20 2026-05-25)ÁÀ뉊]!ÜÛê(¹Þ—šên-5be7b69c3ff7b5b8ÁíàÄTËŸ ÜJîÄ)'ß\¥!-3d1337db07d0b3aeÁ¤²XctÔ'ÐÓ©z¨ɽÓ-a4945860e1c53b00Á¤°ð ¾ä-±($²ï=©Ã-7e98a21bfd32b0edÁòÖÀH•‘PIÓHã#£-055f30b747f859b6Árustc_std_workspace_coreÁ­Cçß^ò½èÝ$­Çÿ+Cé-c4878ee60b2242c9ÁŸÃï+Ñ]ŠqB<ÏïW#-8dd1dd90e70d0b6aÁ miniz_oxideÁ€š»J(P>àö÷g\K-1eb618da2918ab7fÁadler2ÁÆ;+Þ®5¥Ìýݰ¦ÛLˆ-f7919172d268e069Á hashbrownÁPäV9ÒÆèÜ"ÊÖVŽ\-0fc2184a5da6723aÁrustc_std_workspace_allocÁs&ØòØy¯s•bæ!‰ýŠ-97e4bf30be240674Á
std_detectÁhŠBîÙºÌI®ËÅš-9dbbf8346ba7ac8bÁrustc_demangleÁûë9´Ç×@Œ’ùXFº-f33013f239bf9f14Ácfg_ifÁÜLhž§Œaã¯>­-0a71c8f33a838301Á addr2lineÁ׎Þ!]8V$É@@-e618e6be60e87ba2ÁgimliÁ¸
°µ~Î1‹Ñt ðÁ€w-1f7768a68858f670ÁobjectÁ
áPÃ?­À¶¼QHJ¥-914cd6a4dbe590d1ÁmemchrÁ›º«8Ór­2Ù $¨ûib-cf21ca6f2bb15dcdÁë
‹ás«LÖ€îâƒ×ɯŒ-ee6f3747e38367f0ÁÀServiceÁRequestÁResponseÁErrorÁFutureÁ
poll_readyÁÑ'aÁ¤óœ©Ñ¤óœ©Ñ











 ŤóžBoxÁ¡ˆˆ¢ˆl }.xϤçEçEèEGlobalÁ ¿±‡§í#ó

DÚe¼ÚeTãe
ë
ò
,îetãe÷eüƒetœØžØŸØÈ Øˆ¡Ø¢Ø´‰‰Nµý¤ÃÖ¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
ë
ò
Ôµe  ë
L‘e ÌÌkÎwakerÁ¸Ï local_wakerÁ¸ÐextÁ¸Ñ_markerÁ¸Ò_marker2Á¸f'EwÚ]¾åœeŸ¨cxÁ!}§ ÉD¹f´¹f$Âf
ë
ò
,<ÇflÂfÕfüýeXë
ò
L¥fŽL…fò
<frequestÁ&YŒ¤Dåh UniqueÁ žñ
8Åá™-Ýñ¿ § ïíe¼îËè¿*¿ ¿ ¼åhTîh
¿ ñ ÀùhtîhiüŽhtœØžØŸØÈ Øˆ¡Ø¢Ø´‰‰Nµý¤ÃÖ¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
ù
¿ ñ
ÔÀh þ
Lœh§h ¿ ´þ
¼$-Ê1ýßHDÄi ÈŒ¼$´Äi$Íi
¿ ñ P<ÒilÍiàiüˆiX¿ ñ L°iÆLiñ <iÛ¨þ
¼ )-`ç«Àœ‚Øk<æÌ·œØüâiüº30 Definition of the core `Service` trait to TowerÁîúüòJG The [`Service`] trait provides the necessary abstractions for definingÁü½LI request / response clients and servers. It is simple but powerful and isÁüŠ1. used as the foundation for the rest of Tower.ÁÀœƒ‚ØkÌ·œØÈËΜÁʼ«®ÔÂRü÷>; An asynchronous function from a `Request` to a `Response`.ÁúüºIF The `Service` trait is a simplified interface making it easy to writeÁü„JG network applications in a modular and reusable way, decoupled from theÁüÏGD underlying protocol. It is one of Tower's fundamental abstractions.Áú„›
# FunctionalÁ¬úü°FC A `Service` is a function of a `Request`. It immediately returns aÁü÷C@ `Future` representing the eventual completion of processing theÁü»HE request. The actual request processing may happen at any time in theÁü„KH future, on any thread or executor. The processing may depend on callingÁüÐNK other services. At some point in the future, the processing will complete,ÁüŸ 96 and the `Future` will resolve to a response or error.ÁÙ úüÝ PM At a high level, the `Service::call` function represents an RPC request. TheÁü®
0- `Service` value can be a server or a client.Áß
ú
# ServerÁð
úüô
LI An RPC server *implements* the `Service` trait. Requests received by theÁüÁ RO server over the network are deserialized and then passed as an argument to theÁü” FC server value. The returned response is sent back over the network.ÁÛ úüß HE As an example, here is how an HTTP request is processed by a server:Á¨
ú
 ```rustÁĸ
 # use std::pin::Pin;矄
%" # use std::task::{Poll, Context};Áô÷
 # use std::future::Future;Áü–! # use tower_service::Service;Áü¸.+ use http::{Request, Response, StatusCode};Áçú´ë struct HelloWorld;Áúü†30 impl Service<Request<Vec<u8>>> for HelloWorld {Áüº*' type Response = Response<Vec<u8>>;Áüå! type Error = http::Error;Áü‡YV type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;ÁáúüåYV fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {Áü¿ Poll::Ready(Ok(()))ÁéúüíC@ fn call(&mut self, req: Request<Vec<u8>>) -> Self::Future {Áô± // create the bodyÁüÐ1. let body: Vec<u8> = "hello, world!\n"ÁÜ‚ .as_bytes()Áäž .to_owned();Áü»'$ // Create the HTTP responseÁüã*' let resp = Response::builder()ÁüŽ'$ .status(StatusCode::OK)Áܶ .body(body)ÁüÒ=: .expect("Unable to create `http::Response`");Áúü”-* // create a response in a future.Áì let fut = async {ÁÄà Ok(resp)Á };ÁˆúüŒ96 // Return the response as an immediate futureÁÌÆ Box::pin(fut)ÁØ* ```Áøú # ClientÁúüJG A client consumes a service by using a `Service` value. The client mayÁüØMJ issue requests by invoking `call` and passing the request as an argument.Áü¦EB It then receives the response by waiting for the returned future.Áìúüð?< As an example, here is how a Redis request would be issued:Á°ú”´ ```rust,ignoreÁüÇ%" let client = redis::Client::new()Áüí30 .connect("127.0.0.1:6379".parse().unwrap())Á”¡ .unwrap();Á´úü¸OL let resp = client.call(Cmd::set("foo", "this is the value of foo")).await?;ÁˆúüŒ%" // Wait for the future to resolveÁü²+( println!("Redis response: {:?}", resp);Á1æúÄê # Middleware / LayerÁƒúü‡KH More often than not, all the pieces needed for writing robust, scalableÁüÓKH network applications are the same no matter the underlying protocol. ByÁüŸMJ unifying the API for both clients and servers in a protocol agnostic way,ÁüíEB it is possible to write middleware that provide these pieces in aÁŒ³ reusable way.ÁÅúüÉ  Take timeouts as an example:Áêúœ%üú use tower_service::Service;ÁÜš use tower_layer::Layer;Áܶ use futures::FutureExt;ÁäÒ use std::future::Future;Áüï# use std::task::{Context, Poll};Áä“  use std::time::Duration;Á´°  use std::pin::Pin;ÁŒÇ  use std::fmt;ÁÔÙ  use std::error::Error;Áô úüø ;8 // Our timeout service, which wraps another service andÁü´!-* // adds a timeout to its response future.ÁÜâ! pub struct Timeout<T> {ÁŒþ! inner: T,ÁÔ" timeout: Duration,Á,«"1±"úĵ" impl<T> Timeout<T> {ÁüÎ"EB pub const fn new(inner: T, timeout: Duration) -> Timeout<T> {Á¬”# Timeout {Á´ª# inner,Á¼Á# timeoutÁlÙ#
Lç#Ø*,ñ#1÷#úüû#;8 // The error returned if processing a request timed outÁ¤·$ #[derive(Debug)]Á¼Ì$ pub struct Expired;Áä$úüè$# impl fmt::Display for Expired {ÁüŒ%B? fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {ÁüÏ%  write!(f, "expired")ÁLð%Ø*,ú%1€&úì„& impl Error for Expired {}Á¢&úü¦&HE // We can implement `Service` for `Timeout<T>` if `T` is a `Service`Áüï&41 impl<T, Request> Service<Request> for Timeout<T>ÁL¤' whereÁä®' T: Service<Request>,ÁÜË' T::Future: 'static,Áüç'?< T::Error: Into<Box<dyn Error + Send + Sync>> + 'static,Áì§( T::Response: 'static,Á,Å(üË(TQ // `Timeout` doesn't modify the response type, so we use `T`'s response typeÁü )$! type Response = T::Response;ÁüÅ)XU // Errors may be either `Expired` if the timeout expired, or the inner service'sÁüž*eb // `Error` type. Therefore, we return a boxed `dyn Error + Send + Sync` trait object to eraseÁä„+ // the error's type.Áü¡+2/ type Error = Box<dyn Error + Send + Sync>;ÁüÔ+YÞ(®,úü²,YÍ)üŒ-JG // Our timeout service is ready if the inner service is ready.Áü×-\Y // This is how backpressure can be propagated through a tree of nested services.Áü´.85 self.inner.poll_ready(cx).map_err(Into::into)ÁLí.Ø*÷.úüû.:7 fn call(&mut self, req: Request) -> Self::Future {Áü¶/B? // Create a future that completes after `self.timeout`Áüù/;8 let timeout = tokio::time::sleep(self.timeout);Áµ0úü¹0TQ // Call the inner service and get a future that resolves to the responseÁüŽ1+( let fut = self.inner.call(req);Áº1úü¾1`] // Wrap those two futures in another future that completes when either one completesÁtŸ2 //Áü®2VS // If the inner service is too slow the `sleep` future will complete firstÁü…3[X // And an error will be returned and `fut` will be dropped and not polled againÁtá3ÄQüð3;8 // We have to box the errors so the types matchÁü¬4  let f = async move {ÁüÍ4  tokio::select! {Áüî4" res = fut => {Áü‘552 res.map_err(|err| err.into())Á´Ç5 },ÁüÞ5$! _ = timeout => {Áüƒ6NK Err(Box::new(Expired) as Box<dyn Error + Send + Sync>)Á´Ò6°UŒé6tû6ù/Š7ú¼Ž7 Box::pin(f)ÁL¦7Ø*,°71¶7úüº71. // A layer for wrapping services in `Timeout`Áüì7&# pub struct TimeoutLayer(Duration);Á“8ú¼—8 impl TimeoutLayer {Áü¯830 pub const fn new(delay: Duration) -> Self {Áüã8 TimeoutLayer(delay)ÁLƒ9Ø*,91“9úü—9'$ impl<S> Layer<S> for TimeoutLayer {Áü¿9" type Service = Timeout<S>;Áâ9úüæ930 fn layer(&self, service: S) -> Timeout<S> {Áüš:)& Timeout::new(service, self.0)ÁLÄ:Ø*,Î:1<Ô:1Ü:úüà:NK The above timeout implementation is decoupled from the underlying protocolÁü¯;MJ and is also decoupled from client or server concerns. In other words, theÁüý;IF same timeout middleware could be used in either a client or a server.ÁÇ<ú”Ë< # BackpressureÁÞ<úüâ<YV Calling a `Service` which is at capacity (i.e., it is temporarily unable to process aÁü¼=NK request) should result in an error. The caller is responsible for ensuringÁü‹>GD that the service is ready to receive the request before calling it.ÁÓ>úü×>LI `Service` provides a mechanism by which the caller is able to coordinateÁü¤?PM readiness. `Servic
Íì¬sñ t‹SìsÍì¬sñ
\ÇS‹tÍì¬sñ üûSB‚زtüˆT4²tƒØÖ¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
ôs“tüT,ªt}ÄtqÕt

lSüãR# Responses given by the service.ÁDSTÇSüŸS# Errors produced by the service.Á,ÌSüûSAôØS The future response value.Á4€Tü‰^PüÃTOL Returns `Poll::Ready(Ok(()))` when the service is able to process requests.Á—UúüŸUPM If the service is at capacity, then `Poll::Pending` is returned and the taskÁüôUFC is notified when the service becomes ready again. This function isÁü¿VKH expected to be called while on a task. Generally, this can be done withÁüW-* a simple `futures::future::poll_fn` call.ÁÁWúüÉW[X If `Poll::Ready(Err(_))` is returned, the service is no longer able to service requestsÁü©X74 and the caller should discard the service instance.ÁåXúüíXWT Once `poll_ready` returns `Poll::Ready(Ok(()))`, a request may be dispatched to theÁüÉYJG service using `call`. Until a request is dispatched, repeated calls toÁü˜ZSP `poll_ready` must return either `Poll::Ready(Ok(()))` or `Poll::Ready(Err(_))`.ÁðZúüøZYV Note that `poll_ready` may reserve shared resources that are consumed in a subsequentÁüÖ[\Y invocation of `call`. Thus, it is critical for implementations to not assume that `call`Áü·\[X will always be invoked and to ensure that such resources are released if the service isÁü—]ZW dropped before `call` is invoked or the future returned by `call` is dropped before itÁtö] is polled.ÁTŒ^ ! ¬s  ÌÌkδ
¸ÏÇ
¸Ðà
¸Ññ
¸Ò¸f'EwÚ]¾å!œØžØŸØÈ Øˆ¡Ø¢Ø´‰‰Nµý¤ÃÖ¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
ù
“t —^
¬sñ $œ^Ê¢^ü–c1üß^?< Process the request and return the response asynchronously.Á£_úü«_?< This function is expected to be callable off task. As such,Áüï_>; implementations should take care to not call `poll_ready`.Á²`úüº`HE Before dispatching a request, `poll_ready` must be called and returnÁÔ‡a `Poll::Ready(Ok(()))`.Á¦aúd®a # PanicsÁ¿aúüÇaGD Implementations are permitted to panic if `call` is invoked withoutÁü“b63 obtaining `Poll::Ready(Ok(()))` from `poll_ready`.Á.üÎbC3futures do nothing unless you `.await` or poll themÁ$™c" "¬sñ ²t žc
¬sñ $£creqÁ©cüËcWŤóÍìë
ÔcÍìò
<×cë
ò
„Œdë
ÅŸdå
 
  
Ðc[]Z\l©dD®dë
ò
TÊd,Ïdü
\åd4êdËüƒeLT†e#$%