Files
boc/rust-service/target/debug/deps/libtower-51e1af7fe7f33300.rmeta
T

51 lines
33 KiB
Plaintext
Raw Normal View History

rust
#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Á tower_layerÁX*ø6êWHNᕈf§-ee72e88a461fccddÁ
tower_serviceÁ:`¡{¶aÛ¬í"aô-3b2010b03e380b78Á
opaque_futureÁl|»utilÁ„» spawn-readyÁ¼%»filterÁ”B»makeÁ„Zü cbalanceÁ<â:» œ‘:bufferÁ4À;»­ ”ñ:discoverÁD¡<»É ¤Î;î4€=»î”±<hedgeÁ,Û=»ý ŒŽ=limitÁ,µ>»˜
Œè=¬$?»¬„Â> load_shedÁLî?» load-shedÁ¬™?ÿ$Ë@»ÿ„€@ ready_cacheÁ\°A» ready-cacheÁ¼×@ reconnectÁL˜B»³ ¬ÃAretryÁ,öB»Ò Œ©B spawn_readyÁ\ÜC»Ø¼ƒCsteerÁ,¼D»Ž ŒïCtimeoutÁ<šE»© œÉDÉ$ôE»É„©E
service_fnÁT‰G»É„¢F
ServiceExtÁT•G»É " MakeServiceÁ\ÇH»ÿ„àGÀmacrosÁbuilderÁ >
æ layerÁ¥layer_fnÁ
into_innerÁserviceÁ¤ check_cloneÁcheck_service_cloneÁ¤
check_serviceÁ¤¥¦  ×#¤##ServiceÁ#žž(((((É---sealedÁ4SealedÁ5¥BoxErrorÁServiceBuilderÁ88ž;;ƒ
"
"
"
'
=
5Ø88ï:ž›qA‚B´Êî³88ï:ž›qA‚B´ÊîääIdentityÁå_pÁÅÝüdõ«Ò¿c¾Ú88ï:ž›qA‚B´Êî¤;8 8 8#8س¿cÚ(47ÀïtÊG81LayerÁ,øHÚ2ô<¥IÙJüÌ2/ `async fn(Request) -> Result<Response, Error>`Áÿú # OverviewÁúü–FC Tower is a library of modular and reusable components for buildingÁüÝ*' robust networking clients and servers.ÁˆúüŒJG Tower provides a simple core abstraction, the [`Service`] trait, whichÁü×OL represents an asynchronous function taking a request and returning either aÁü§PM response or an error. This abstraction can be used to model both clients andÁ servers.Áúü‰OL Generic components, like [timeouts], [rate limiting], and [load balancing],ÁüÙIF can be modeled as [`Service`]s that wrap some inner service and applyÁü£PM additional behavior before or after the inner service is called. This allowsÁüôTQ implementing these components in a protocol-agnostic, composable way. Typically,ÁüÉ2/ such services are referred to as _middleware_.Áüúü€ FC An additional abstraction, the [`Layer`] trait, is used to composeÁüÇ JG middleware with [`Service`]s. If a [`Service`] can be thought of as anÁü’
PM asynchronous function from a request type to a response type, a [`Layer`] isÁüã
PM a function taking a [`Service`] of one type and returning a [`Service`] of aÁü´ NK different type. The [`ServiceBuilder`] type is used to add middleware to aÁüƒ 52 service by composing it with multiple [`Layer`]s.Á¹ úÔ½  ## The Tower EcosystemÁØ úüÜ -* Tower is made up of the following crates:ÁŠ
úäŽ
 * [`tower`] (this crate)Á¼«
 * [`tower-service`]Á¬Ã
 * [`tower-layer`]Á¤Ù
 * [`tower-test`]Áî
úüò
OL Since the [`Service`] and [`Layer`] traits are important integration pointsÁüÂKH for all libraries using Tower, they are kept as stable as possible, andÁüŽMJ breaking changes are made rarely. Therefore, they are defined in separateÁüÜFC crates, [`tower-service`] and [`tower-layer`]. This crate containsÁü£EB re-exports of those core traits, implementations of commonly-usedÁüéMJ middleware, and [utilities] for working with [`Service`]s and [`Layer`]s.Áü·OL Finally, the [`tower-test`] crate provides tools for testing programs usingÁT‡ Tower.Áú\ # UsageÁ¢úü¦OL Tower provides an abstraction layer, and generic implementations of variousÁüöOL middleware. This means that the `tower` crate on its own does *not* provideÁüÆLI a working implementation of a network client or server. Instead, Tower'sÁü“FC [`Service` trait][`Service`] provides an integration point betweenÁüÚIF application code, libraries providing middleware implementations, andÁü¤GD libraries that implement servers and/or clients for various networkÁ protocols.ÁûúüÿOL Depending on your particular use case, you might use Tower in several ways:ÁÏúüÓKH * **Implementing application logic** for a networked program. You mightÁüŸMJ use the [`Service`] trait to model your application's behavior, and useÁüíNK the middleware [provided by this crate](#modules) and by other librariesÁü¼IF to add functionality to clients and servers provided by one or moreÁü† protocol implementations.Áü¦OL * **Implementing middleware** to add custom behavior to network clients andÁüöLI servers in a reusable manner. This might be general-purpose middlewareÁüÃOL (and if it is, please consider releasing your middleware as a library forÁü“KH other Tower users!) or application-specific behavior that needs to beÁüß1. shared between multiple clients or servers.Áü‘KH * **Implementing a network protocol**. Libraries that implement networkÁüÝGD protocols (such as HTTP) can depend on `tower-service` to use theÁü¥MJ [`Service`] trait as an integration point between the protocol and userÁüóPM code. For example, a client for some protocol might implement [`Service`],ÁüÄHE allowing users to add arbitrary Tower middleware to those clients.ÁüLI Similarly, a server might be created from a user-provided [`Service`].ÁÚúüÞJG Additionally, when a network protocol requires functionality alreadyÁü© PM provided by existing Tower middleware, a protocol implementation might useÁüú FC Tower middleware internally, as well as as an integration point.ÁÁ!ú´Å! ## Library SupportÁÜ!úüà!NK A number of third-party libraries support Tower and the [`Service`] trait.Áü¯":7 The following is an incomplete list of such libraries:Áê"úüî"B? * [`hyper`]: A fast and correct low-level HTTP implementation.Áü±#JG * [`tonic`]: A [gRPC-over-HTTP/2][grpc] implementation built on top ofÁüü#PM [`hyper`]. See [here][tonic-examples] for examples of using [`tonic`] withÁdÍ$ Tower.ÁüÚ$<9 * [`warp`]: A lightweight, composable web framework. SeeÁü—%DA [here][warp-service] for details on using [`warp`] with Tower.ÁüÜ%OL * [`tower-lsp`] and its fork, [`lspower`]: implementations of the [La
3Ï Ï Ï ¬ô94ƒ:|ûEü0- Builder types to compose layers and servicesÁ<ƒF8©DDäí,NÚStackÁ,Uòô<p ׃¤,
\6_aQS>@´a3D~'üñ)õ ´ ¤¡õ 
ìÕõ¤¢üù$! Create a new [`ServiceBuilder`].Á©õ

̉Íìè Ž¾ü­ >ü©41 Add a new layer `T` into the [`ServiceBuilder`].ÁâúüêLI This wraps the inner service with the service provided by a user-definedÁü»EB [`Layer`]. The provided layer must implement the [`Layer`] trait.ÁúÜ üO,´ ¾¥88ï:ž›qA‚B´ÊîòòýVõinnerÁöouterÁÈ­ù—…]è¥Íì…] º 
è…]žü*Tü½(]Z Add a [`Layer`] built from a function that accepts a service and returns another service.ÁŸ)úü§)<9 See the documentation for [`layer_fn`] for more details.Áè)úüð)(% [`layer_fn`]: crate::layer::layer_fnÁD¤*¾88ï:ž›qA‚B´ÊîòòýVõÇ\ö×\È­ù—êêLayerFnÁì±äƒ5ظ³ç`èÍìç` ­*
èç`$°*± ¶*䵉üþˆ2/ Returns the underlying `Layer` implementation.ÁT¼‰¾è
è$ljüÇ‹Qüò‰=: Wrap the service `S` with the middleware provided by thisÁü´ŠB? [`ServiceBuilder`]'s [`Layer`]'s, returning a new [`Service`].ÁûŠú܃‹üOü£‹ÔO<΋> ¤èÈeܤ Ù‹ÍìÈe Ö‹ÚèÈeDŒ
èÈe$Ú‹Ø<à‹35üÖŸ?ü€™.+ Check that the builder implements `Clone`.Á³™úü»™[X This can be useful when debugging type errors in `ServiceBuilder`s with lots of layers.Á›šúü£šC@ Doesn't actually change the builder but serves as a type check.Áëšúlóš
# ExampleÁ…›ú\ ```rustÁô use tower::ServiceBuilder;ÁÀ›úüÈ›'$ let builder = ServiceBuilder::new()Áüô›52 // Do something before processing the requestÁü®œ(% .map_request(|request: String| {ÁüÛœ%" println!("got request!");Áœ… requestÁT })Áü¬41 // Ensure our `ServiceBuilder` can be clonedÁ´å .check_clone()Áü€ž41 // Do something after processing the requestÁü¹ž*' .map_response(|response: String| {Áüèž&# println!("got response!");Á¤“Ÿ responseÁ\¬Ÿ });Á<¼ŸßI\ÝŸ¾¾Ø¾, 
è$éŸü¼¨eü´ ^[ Check that the builder when given a service of type `S` produces a service that implementsÁd—¡ `Clone`.Á¨¡úü°¡[žf¢úü˜¢C‘gà¢úlè¢ëgú¢ú\‚£hô’£¤hµ£ú´½£ # #[derive(Clone)]Á¼Ø£ # struct MyService;Á,ô£üþ£'Úhüª¤5Œiüä¤(Ìiü‘¥%ÿiœ»¥®jTÓ¥Ëjüâ¥OL // Ensure that the service produced when given a `MyService` implementsÁü¶¦+( .check_service_clone::<MyService>()Áüæ¦4¿küŸ§*þküΧ&³l¤ù§ãl\’¨m<¢¨ßIœÃ¨¾¾¤ûe רŒfDý¨ØÍe,›©
èÈe$Ú¨/1üœ·üÀ©]Z Check that the builder when given a service of type `S` produces a service with the givenÁü¢ª'$ request, response, and error types.ÁΪúüÖª[žf¶«úü¾«C‘g†¬úlެëg ¬ú\¨¬hô¸¬¤hüÛ¬# use std::task::{Poll, Context};Áüƒ­%" use tower::{Service, ServiceExt};Á­­ú̵­ // An example serviceÁ¬Ó­ struct MyService;Áí­úüõ­)& impl Service<Request> for MyService {Áü£® type Response = Response;ÁÌÇ® type Error = Error;Áüå®IF type Future = futures_util::future::Ready<Result<Response, Error>>;Á³¯úü»¯WT fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {Á„—°
// ...Áœ¬° # todo!()Á<İаúüذ<9 fn call(&mut self, request: Request) -> Self::Future {Á„™±zœ®±©z<ƱÆz,Ò±ܱúœä± struct Request;Á¤ü± struct Response;ÁŒ•² struct Error;Á«²úü³²%" struct WrappedResponse(Response);Áݲúüå²'Úhü‘³YV // At this point in the builder if given a `MyService` it produces a service thatÁüï³LI // accepts `Request`s, produces `Response`s, and fails with `Error`sÁüÀ´?< .check_service::<MyService, Request, Response, Error>()Áü„µ.+ // Wrap responses in `WrappedResponse`Áü·µEB .map_response(|response: Response| WrappedResponse(response))Áü:7 // Now the response type will be `WrappedResponse`ÁüÀ¶=: .check_service::<MyService, _, WrappedResponse, _>();Á<‚·ßIl£·¾¾¤¥¦ûe ±·Íì¥ ´·Íì¦ ··Íì º·ŒfDà·Íe±ƒüþ·#Íe±ƒ Ńd‰¸Íe±ƒ
ÙƒL—¸
èÈe±ƒŃÙƒ$½·§© ¢ü…Ö4!!®Z ŠÖ¿cèTÖ¾"Àc"!#üÀÖ8ÃÖ?@A  @ c cˆ¢cµ
 `£cbufÁ `àB¤GS
AÖ¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
ŸÈŸÈ ÈErrorÁ O˜éBL  ÇÖ
"è$ÈÖ± ÎÖüÈ×@¤$%%$Íì Í×Íì Ð×ÚDÿ×ç&'ÜÝ';=79dØ<”Ø##Üü¯Ø*,²ØB çÜ# ¸Ø#
'$¹ØÇ\,¿ØlŒFü2/ A collection of [`Layer`] based tower servicesÁ3úÜ7üO,”F-±Dj *í,tÚ+Ø`<{ê,\\/1$&ü†" Utilities for combining layersÁ©úü­.+ [`Identity`]: crate::layer::util::IdentityÁÜÜüOüø(% [`Stack`]: crate::layer::util::StackÁ©ä/ýV,Ôò0\¼#%ôºGß ”ëHô ´–I
TÉI4ÍI5œÚI4äI5¥656Îì´ÚI˜^ ëI5êê$ "ŒœJüôI'$ Alias for a type-erased error type.ÁD¥JžBoxÁ¡ˆˆ¢ˆl }.xϾ ÌìçEçEèEGlobalÁ ¿±‡§í#äÁü‰/, Declaratively construct [`Service`] values.Á¹úü½QN [`ServiceBuilder`] provides a [builder-like interface][builder] for composingÁü*' layers to be applied to a [`Service`].Áºú