Trait Extension
pub trait Extension:
Any
+ Send
+ Sync
+ Debug
+ 'static { }Expand description
Extension is type which can be stored inside an Extensions store
This is has to be manually implement or can be implemented using #[derive(Extension)]
We have not implemented this for any container types:
Arc<T>: sounds nice, but by not implement it, it has become impossible to misuseExtensions::insert()withExtensions::insert_arc(). Otherwise this is very tricky and error proneVec<T>: Collections should use the new type pattern to give it a meaningfull name, and to prevent collisions
There might be valid use cases for implementing it for other type of containers, so in case you run into these open a Github issue and we can see if implementing it makes sense
§Extension Tags
Extensions can be tagged with one or more categories using the #[extension(tags(tag1, tag2))]
attribute on the derive macro. This generates implementations for the corresponding
marker traits below, which groups them in rust docs
TlsExtension— TLS and secure transportHttpExtension— HTTP protocolNetExtension— Network and connection levelUaExtension— User-agent emulationProxyExtension— ProxyWsExtension— WebSocketDnsExtension— DNS resolutionGrpcExtension— gRPC
ⓘ
#[derive(Debug, Clone, Extension)]
#[extension(tags(tls, net))]
pub struct SecureTransport(..);Types that implement Extension manually can opt into tagged docs by implementing
the marker trait(s) directly:
ⓘ
impl Extension for MyType {}
impl HttpExtension for MyType {}