Trait ConnectionAdmissionPolicy
pub trait ConnectionAdmissionPolicy:
Debug
+ Send
+ Sync
+ 'static {
// Required methods
fn try_acquire(
&self,
input: &Extensions,
) -> Result<Option<ConnectionAdmissionLease>, Box<dyn Error + Sync + Send>>;
fn watch(&self) -> Pin<Box<dyn Future<Output = ()> + Send>>;
}net only.Expand description
Transport resources required before a pooled connection can be handed out.
Unlike a concurrency limit, this reserves actual availability. A protocol can consume its typed reservation when it starts the request. Implementations must be nonblocking and must not reenter the pool. The pool calls providers outside its storage and admission locks.
Required Methods§
fn try_acquire(
&self,
input: &Extensions,
) -> Result<Option<ConnectionAdmissionLease>, Box<dyn Error + Sync + Send>>
fn try_acquire( &self, input: &Extensions, ) -> Result<Option<ConnectionAdmissionLease>, Box<dyn Error + Sync + Send>>
Reserve one request’s resources, or return None when currently exhausted.
An error permanently rejects this connection: cached connections are
retired and selection continues; failure on a new connection is returned
to the caller. Request compatibility belongs in ConnectionReusePolicy,
not in this resource provider.
Inspect input without mutating it. Return the typed request binding in
the lease; the handout publishes it in an isolated child store when
serving the request.
fn watch(&self) -> Pin<Box<dyn Future<Output = ()> + Send>>
fn watch(&self) -> Pin<Box<dyn Future<Output = ()> + Send>>
Subscribe now to the next availability change.
Subscription must happen before this method returns, rather than when the future is first polled. Wake for returned reservations, peer credit, and terminal connection changes. Spurious notifications are permitted.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".