pub struct SharedCfg(/* private fields */);Expand description
An immutable collection of typed configuration values.
Implementations§
Sourcepub fn new(tag: &'static str) -> SharedCfgBuilder
pub fn new(tag: &'static str) -> SharedCfgBuilder
Starts building a shared configuration with the given tag.
Sourcepub fn get<T>(&self) -> Cfg<T>where
T: Configuration,
pub fn get<T>(&self) -> Cfg<T>where
T: Configuration,
Returns the configuration value of type T, or its default.
A value added with SharedCfgBuilder::add is the same instance on
every thread. When T was not added, the first lookup on a thread
creates T::default(), logs it at info level, and caches it for this
shared configuration on that thread. Later lookups on the same thread,
including through CfgContext::get and Cfg::get_shared, return
the cached value; other threads create their own.
A missing value is not an error, and the returned handle does not show
whether the value was added or defaulted. Framework components rely on
this to fall back to their defaults. Add configuration your application
requires explicitly, and validate it where you build the
SharedCfg.
§Panics
A panic in T::default() or Configuration::set_ctx while creating
the default propagates to the caller, and nothing is cached.
Trait Implementations§
Source§fn from(cfg: SharedCfgBuilder) -> SharedCfg
fn from(cfg: SharedCfgBuilder) -> SharedCfg
§fn call(
&self,
req: A,
ctx: Ctx<'_, Connector<A, S>, SharedCfg>,
) -> impl Future<Output = Result<<Connector<A, S> as Service<SharedCfg, A>>::Res, <Connector<A, S> as Service<SharedCfg, A>>::Error>>
fn call( &self, req: A, ctx: Ctx<'_, Connector<A, S>, SharedCfg>, ) -> impl Future<Output = Result<<Connector<A, S> as Service<SharedCfg, A>>::Res, <Connector<A, S> as Service<SharedCfg, A>>::Error>>
Connects to an HTTP/2 server.
§async fn ready(
&self,
ctx: Ctx<'_, Connector<A, S>, SharedCfg>,
) -> Result<(), <Connector<A, S> as Service<SharedCfg, A>>::Error>
async fn ready( &self, ctx: Ctx<'_, Connector<A, S>, SharedCfg>, ) -> Result<(), <Connector<A, S> as Service<SharedCfg, A>>::Error>
§async fn shutdown(&self, ctx: Ctx<'_, Connector<A, S>, SharedCfg>)
async fn shutdown(&self, ctx: Ctx<'_, Connector<A, S>, SharedCfg>)
Source§fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
Source§fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
Source§type Error = Error<ConnectError>
type Error = Error<ConnectError>
Source§async fn call(
&self,
req: Connect<A>,
ctx: Ctx<'_, Connector<A>, SharedCfg>,
) -> Result<Io, <Connector<A> as Service<SharedCfg, Connect<A>>>::Error>
async fn call( &self, req: Connect<A>, ctx: Ctx<'_, Connector<A>, SharedCfg>, ) -> Result<Io, <Connector<A> as Service<SharedCfg, Connect<A>>>::Error>
Source§fn ready(
&self,
ctx: Ctx<'_, Self, St>,
) -> impl Future<Output = Result<(), Self::Error>>
fn ready( &self, ctx: Ctx<'_, Self, St>, ) -> impl Future<Output = Result<(), Self::Error>>
Source§fn shutdown(&self, ctx: Ctx<'_, Self, St>) -> impl Future<Output = ()>
fn shutdown(&self, ctx: Ctx<'_, Self, St>) -> impl Future<Output = ()>
Source§fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
Source§fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
Source§async fn call(
&self,
req: Connect<A>,
ctx: Ctx<'_, SslConnector<S>, SharedCfg>,
) -> Result<<SslConnector<S> as Service<SharedCfg, Connect<A>>>::Res, <SslConnector<S> as Service<SharedCfg, Connect<A>>>::Error>
async fn call( &self, req: Connect<A>, ctx: Ctx<'_, SslConnector<S>, SharedCfg>, ) -> Result<<SslConnector<S> as Service<SharedCfg, Connect<A>>>::Res, <SslConnector<S> as Service<SharedCfg, Connect<A>>>::Error>
Establishes transport, then upgrades it using the normalized request host.
Source§type Error = Error<ConnectError>
type Error = Error<ConnectError>
Source§fn ready(
&self,
ctx: Ctx<'_, SslConnector<S>, SharedCfg>,
) -> impl Future<Output = Result<(), <SslConnector<S> as Service<SharedCfg, Connect<A>>>::Error>>
fn ready( &self, ctx: Ctx<'_, SslConnector<S>, SharedCfg>, ) -> impl Future<Output = Result<(), <SslConnector<S> as Service<SharedCfg, Connect<A>>>::Error>>
Source§fn shutdown(
&self,
ctx: Ctx<'_, SslConnector<S>, SharedCfg>,
) -> impl Future<Output = ()>
fn shutdown( &self, ctx: Ctx<'_, SslConnector<S>, SharedCfg>, ) -> impl Future<Output = ()>
Source§fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
Source§fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
Source§async fn call(
&self,
req: Connect<A>,
ctx: Ctx<'_, TlsConnector<S>, SharedCfg>,
) -> Result<<TlsConnector<S> as Service<SharedCfg, Connect<A>>>::Res, <TlsConnector<S> as Service<SharedCfg, Connect<A>>>::Error>
async fn call( &self, req: Connect<A>, ctx: Ctx<'_, TlsConnector<S>, SharedCfg>, ) -> Result<<TlsConnector<S> as Service<SharedCfg, Connect<A>>>::Res, <TlsConnector<S> as Service<SharedCfg, Connect<A>>>::Error>
Establishes transport first, then validates the server name and times the TLS handshake.
Source§type Error = Error<ConnectError>
type Error = Error<ConnectError>
Source§fn ready(
&self,
ctx: Ctx<'_, TlsConnector<S>, SharedCfg>,
) -> impl Future<Output = Result<(), <TlsConnector<S> as Service<SharedCfg, Connect<A>>>::Error>>
fn ready( &self, ctx: Ctx<'_, TlsConnector<S>, SharedCfg>, ) -> impl Future<Output = Result<(), <TlsConnector<S> as Service<SharedCfg, Connect<A>>>::Error>>
Source§fn shutdown(
&self,
ctx: Ctx<'_, TlsConnector<S>, SharedCfg>,
) -> impl Future<Output = ()>
fn shutdown( &self, ctx: Ctx<'_, TlsConnector<S>, SharedCfg>, ) -> impl Future<Output = ()>
Source§fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
Source§fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
Auto Trait Implementations§
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.