pub trait HandlerBuilder<'a, OldRD>{
// Provided methods
fn at<H>(
self,
path: &'a [&'a str],
handler: H,
) -> ForkingHandler<'a, H, Self>
where H: Handler + Sized { ... }
fn at_with_attributes<H>(
self,
path: &'a [&'a str],
attributes: &'a [Attribute],
handler: H,
) -> ForkingHandler<'a, ConstantSingleRecordReport<'a, H>, Self>
where H: Handler + Sized { ... }
fn below<H>(
self,
path: &'a [&'a str],
handler: H,
) -> ForkingTreeHandler<'a, H, Self> { ... }
}
Expand description
Trait implemented by default on all handlers that lets the user stack them using a builder-like syntax.
Note that the resulting ForkingRequestData<ForkingRequestData<…>,()> enums that might look wasteful on paper are optimized into the minimum necessary size since https://github.com/rust-lang/rust/pull/45225. They are, however, suboptimal when it comes to how many times the options are read.
Provided Methods§
Sourcefn at<H>(self, path: &'a [&'a str], handler: H) -> ForkingHandler<'a, H, Self>
fn at<H>(self, path: &'a [&'a str], handler: H) -> ForkingHandler<'a, H, Self>
Divert requests arriving at path
into the given handler
.
The handler will not not see the Uri-Path (and Uri-Host, as this builder doesn’t do virtual hosting yet) options any more; see the top-level module documentation on Options Hiding for rationale.
If both the previous tree and the new handler are Reporting, so is the result.
Sourcefn at_with_attributes<H>(
self,
path: &'a [&'a str],
attributes: &'a [Attribute],
handler: H,
) -> ForkingHandler<'a, ConstantSingleRecordReport<'a, H>, Self>
fn at_with_attributes<H>( self, path: &'a [&'a str], attributes: &'a [Attribute], handler: H, ) -> ForkingHandler<'a, ConstantSingleRecordReport<'a, H>, Self>
Divert requests arriving at path
into the given handler
, and announce them with the
given attributes in .well-known/core.
Any reporting the handler would have done is overridden.
This is a shorthand for .at(ConstantSingleRecordReport::new(h, attributes))
.
Sourcefn below<H>(
self,
path: &'a [&'a str],
handler: H,
) -> ForkingTreeHandler<'a, H, Self>
fn below<H>( self, path: &'a [&'a str], handler: H, ) -> ForkingTreeHandler<'a, H, Self>
Divert requests arriving with an Uri-Path starting with path
to the given handler
.
Only remaining Uri-Path options will be visible to the handler; those expressed in path (and Uri-Host, see [.at()]) are hidden.
If both the previous tree and the new handler are Reporting, so is the result.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.