Files
archy/core/target/debug/deps/libtower-3320f9262af9c89d.rmeta
T

64 lines
34 KiB
Plaintext
Raw Normal View History

rust
¡†#rustc 1.93.0 (254b59607 2026-01-19)Áõ…·fÊ ¦%g--c48c539199cbc88bÁ³VOÐêùÿ²?ÑL¼§Ì±-a7a40eb546f9e2b0Áá\ƒ¦è3$|]åŒ[IÚ tæ-14b12edc9f8cd90bÁë&Gf·Ã ¬ëñq:¤»b-bb76018b1173caf6Áà 9m Ù„«ÐÒþá•cB;-030c5b0bba47cc8fÁrustc_std_workspace_coreÁÛ¹þÓ7>H%¸ÚÉ­-4b81d37a5530864dÁüÃùs<Uß7VyóHr#QÏ-c66cc7807550ce25Á miniz_oxideÁõFÖˆÚ™ª‹"ÞXzLVª-62cbc7af83058505Áadler2Á—wÉD‘嵯|6¨%Œ
+-2f171dd2394b4b62Á hashbrownÁ,ïcV¼¨ø¢:Ê\'È߈-9571ba9e0f6c7a90Árustc_std_workspace_allocÁ%¥Èxµù·¼5Ä3Bœ-aac566ad65903fa4Á
std_detectÁMmáýZ^9õ Îà§e˜÷e-2edb296e590136d8Árustc_demangleÁ@¼§VÉNb˜æ¨fHÌ+V3-53b132e4a2fa6e26Ácfg_ifÁfÝv.Å"ÒÜuPp¹ˆ¶-f76b385d7d4d7f3eÁ addr2lineÁÕú-WiúQVÓ¬
µT§5-fe25100bd73e48e4ÁgimliÁ¹xLáÇí÷‘o±Ñ8£Å-265ba9e6e4f70b3fÁobjectÁÔ³ÝzÓÿ¶ò°öM›¼òü`-9ae0d1f8ea52a318ÁmemchrÁRÎ÷׎™te~QÓ¿ØC\Ò-0bff3c8e8f4e489eÁ  –©HtGNÏ·ˆ!á-d69228d077d46f36Á tower_layerÁŸR1Ä‘ç.¥÷Y
qP\õ-bf470bb9a123643cÁ
tower_serviceÁ'²4"´V \OZEBó-4cdd26a04149612eÁ
opaque_futureÁl|<utilÁ4<% spawn-readyÁl/¼%<BfilterÁDL”B<ZmakeÁ4d„Zü cbalanceÁ<»9<9¨ L§9œ9bufferÁ4ç9<Ê9Í DÔ9”Ê9discoverÁD”:<õ9ñ Tÿ9¤õ9ý4Á:<¤:ýD®:”¤:hedgeÁ,ë:<Ï:µ
<Ù:ŒÏ:limitÁ,”;<ø:Ø
<;Œø:Ù $¼;<¡;Ù 4«;„¡; load_shedÁLè;<È; load-shedÁ\Ò;¬È;” $•<<ú;” 4„<„ú; ready_cacheÁ\Ã<<¡< ready-cacheÁl«<¼¡< reconnectÁLö<<Ö< \à<¬Ö<retryÁ,£=<‡= <=Œ‡= spawn_readyÁ\Ò=<°=álº=¼°=steerÁ,><å=Ž
<ï=Œå=timeoutÁ<¬><Ž>±
L˜>œŽ>Ì$Ö><»>Ì4Å>„»>
service_fnÁTë?<„?Ì4Ž?„„?
ServiceExtÁT÷?(Ì&$& MakeServiceÁ\ªA<Ã@” 4Í@„Ã@sealedÁ4ûB<¸B¨ LÂBœ¸B<ÍBñ T×B¤ÍB<ãB” 4íB„ãBü·B=macrosÁbuilderÁ >
 layerÁlayer_fnÁ
into_innerÁserviceÁ check_cloneÁcheck_service_cloneÁç
check_serviceÁç  Í#ç##ServiceÁ#žž(((((Ì---BoxErrorÁServiceBuilderÁ55ž88È
"
"
"
'
:
Þ55Ò7žæûγ¿ ë¸Ä55Ò7žæûγ¿ ë¸ääIdentityÁå_pÁÇIå;Ñ( ºà` Ú55Ò7žæûγ¿ ë¸ç85 5 5#5ÞÄà`Ú@äÉ
ßÉ,4(¹
5ɾ:+ 6  @É ÉZdÇ¥

&üÇ>
5ÿ ü¢iÖÿsT²!Éì !T !
"É,«!:/üü L
5òòStackÁõinnerÁöouterÁ:ÖᎠ@$ÉÎ!ü³ ›55Ò7žæûγ¿ ë¸´ÜÖ  ´ùÉ#ž'{*$Î*
&ÌÙ*´Ù*
À ð*'üÎ*% ,Ó*
ÉêêLayerFnÁìþð£$Ä׋]íÂüÓ*  ò*
ù*üï)Š,<155Ò7žæûγ¿ ë¸òò¾õÌöÜ:ÖᎠ@$°Éü‘*2 $‚*í ˆ* ²°ê*þ.êè·¨ T’ƒÉ¢ƒüë‚7É †ƒ $ý‚ /TÝ…ÉÌÝ…,è…
ÝÉç8<î…tè…ü…üý„ɺ ÜT¥…,º <–…ª˜Ù W± «$¦™°™üؘX $ô˜ $ë˜ /$²¢¼¢ü¾¡~ $å¡ $Ü¡ /$ª±´±ü•°Ÿ $¿° $¶° 0„Øß  üÊß\Ìß
¦a Êß=ìÌß3\ðßÉ à`üÊß2,êß
‘^ŽS”êßüÊß;4ýß
˜^RDýß‹à"ü‡ß ê³í³î³Òï³ìð³ñ³ò³ìäs{©¶ѼѼÒ¼ štÀ.\´ß,Žß Á`Á`œÃ`è Á]Ä`bufÁÁ]Ê­\É:• •ß „^„^
DebugTupleÁ‡^ÍÖ]ˆ^Û
Ö]‰^fieldsÁÖ]Š^
empty_nameÁÖ]JžÛœŽ÷³ÕÄÍ'<Ï'D„$eì$ªóþ¸šœ$ªì$OŒ%%À%÷T«áKá,¶á
Ýïõ5,¼ád¶áÈá'üöàRïõÜl“á Æ,ÿàõ,†á ï Ì#]Ø)®(4Òt¬@51LayerÁ,ÜAÚ2ø<ŠB‡DüÌ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.ÁËü‰PM Generic components, like [`timeout`], [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.ÁüÝ%52 * [`tower-lsp`]: implementations of the [LanguageÁü“&+( Server Protocol][lsp] based on Tower.Á¿&ËüÃ&-* [`hyper`]:
ü6%[]MO?A´a4D~(üñ)Ö Å ¤¡Ö 
ìÕÖÔ¢üù$! 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.Á ËÜ“ Ëd,º  £©â À 
ÉØ žá üï)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ö) í×À©âí ÿ)
ÉíÇþÐäë‚ü´‚2/ Returns the underlying `Layer` implementation.ÁTò‚ É
Éfüý„Qü¨ƒ=: Wrap the service `S` with the middleware provided by thisÁüêƒB? [`ServiceBuilder`]'s [`Layer`]'s, returning a new [`Service`].Á±„Ëܹ„ËdüÙ„¤d<„…; º ø ç ©âº Œ…Úɺ DÅ…
ɺ $Ù13üؘ?ü‚’.+ 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Á\®˜ });Á<¾˜Ì^\ߘ  Þ ,‘™
Éü¾¡eü¶™^[ Check that the builder when given a service of type `S` produces a service that implementsÁd™š `Clone`.ÁªšËü²š[÷w’›Ëüš›Cèxâ›Ëlê›Àyü›Ë\„œâyô”œöy·œË´¿œ # #[derive(Clone)]Á¼Úœ # struct MyService;Á,öœü€'ªzü¬5Ûzüæ(š{ü“ž%Ì{œ½žú{TÕž–|üäžOL // Ensure that the service produced when given a `MyService` implementsÁü¸Ÿ+( .check_service_clone::<MyService>()ÁüèŸ4‡}ü¡ *Å}üР&ù}¤û ¨~\”¡Å~<¤¡Ì^œÅ¡  çÙw Ù¡êwDÿ¡Þø ,¢
ɺ î-/ü•°ü¢]Z Check that the builder when given a service of type `S` produces a service with the givenÁü¤£'$ request, response, and error types.ÁУËüØ£[÷w¸¤ËüÀ¤Cèxˆ¥Ël¥Ày¢¥Ë\ª¥âyôº¥öyüÝ¥# 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;Áüç§@= type Future = std::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 {Á„’ªŽ‹œ§ª§‹<¿ªË,˪ժ˜ݪ struct Request;Á¤õª struct Response;ÁŒŽ« struct Error;Á¤«Ëü¬«%" struct WrappedResponse(Response);ÁÖ«ËüÞ«'ªzüЬ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, _>();Á<û¯Ì^lœ°  çÄÌÙw ª°©â ­°©âÄ °°©âÌ ³°êwDÙ°ø š”ü÷°#ø š” ®”d‚±ø š”