Struct drought::droughter::DroughterBuilder
source · pub struct DroughterBuilder { /* private fields */ }
Expand description
A builder struct for Droughter
.
See the module-level docs for more.
Implementations§
source§impl DroughterBuilder
impl DroughterBuilder
pub fn new() -> Self
sourcepub fn insert_drought(&mut self, priority: usize, drought: impl Drought + 'static)
pub fn insert_drought(&mut self, priority: usize, drought: impl Drought + 'static)
Adds an arbitrary Drought
to the resulting Droughter
,
with the specified priority level.
sourcepub fn with_drought(
self,
priority: usize,
drought: impl Drought + 'static
) -> Self
pub fn with_drought(
self,
priority: usize,
drought: impl Drought + 'static
) -> Self
A chainable version of insert_drought
.
sourcepub fn insert_sub(&mut self, priority: usize, path: &str, droughter: Droughter)
pub fn insert_sub(&mut self, priority: usize, path: &str, droughter: Droughter)
Creates a new Drought
, which ferries requests to a
Droughter
, if the resource name matches path
.
sourcepub fn with_sub(self, priority: usize, path: &str, droughter: Droughter) -> Self
pub fn with_sub(self, priority: usize, path: &str, droughter: Droughter) -> Self
A chainable version of insert_sub
.
sourcepub fn insert_typed<T: FromStr + 'static>(
&mut self,
priority: usize,
name: &str,
droughter: Droughter
)
pub fn insert_typed<T: FromStr + 'static>(
&mut self,
priority: usize,
name: &str,
droughter: Droughter
)
Creates a new Drought
, which ferries requests to a
Droughter
, if the resource name is parseable as T
.
The match gets stored in the Matches
as name
.
sourcepub fn with_typed<T: FromStr + 'static>(
self,
priority: usize,
name: &str,
droughter: Droughter
) -> Self
pub fn with_typed<T: FromStr + 'static>(
self,
priority: usize,
name: &str,
droughter: Droughter
) -> Self
A chainable version of insert_typed
.
sourcepub fn insert_matched(
&mut self,
priority: usize,
name: &str,
regex: Regex,
droughter: Droughter
)
pub fn insert_matched(
&mut self,
priority: usize,
name: &str,
regex: Regex,
droughter: Droughter
)
Creates a new Drought
, which ferries requests to a
Droughter
, if the resource name matches regex
.
The match gets stored in the Matches
as name
.
sourcepub fn with_matched(
self,
priority: usize,
name: &str,
regex: Regex,
droughter: Droughter
) -> Self
pub fn with_matched(
self,
priority: usize,
name: &str,
regex: Regex,
droughter: Droughter
) -> Self
A chainable version of insert_matched
.
sourcepub fn insert_lambda(
&mut self,
priority: usize,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: Matches) -> Pin<Box<dyn Future<Output = DroughtResult> + 'a>>
)
pub fn insert_lambda(
&mut self,
priority: usize,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: Matches) -> Pin<Box<dyn Future<Output = DroughtResult> + 'a>>
)
Creates a new Drought
, which will directly pass calls to
Drought::handle
to func
.
sourcepub fn with_lambda(
self,
priority: usize,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: Matches) -> Pin<Box<dyn Future<Output = DroughtResult> + 'a>>
) -> Self
pub fn with_lambda(
self,
priority: usize,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: Matches) -> Pin<Box<dyn Future<Output = DroughtResult> + 'a>>
) -> Self
A chainable version of insert_lambda
.
sourcepub fn insert_request_irrigator(
&mut self,
irrigator: impl RequestIrrigator + 'static
)
pub fn insert_request_irrigator(
&mut self,
irrigator: impl RequestIrrigator + 'static
)
Adds an arbitrary RequestIrrigator
to the resulting Droughter
.
sourcepub fn with_request_irrigator(
self,
irrigator: impl RequestIrrigator + 'static
) -> Self
pub fn with_request_irrigator(
self,
irrigator: impl RequestIrrigator + 'static
) -> Self
A chainable version of insert_request_irrigator
.
sourcepub fn insert_request_irrigator_lambda(
&mut self,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: Matches) -> Pin<Box<dyn Future<Output = IrrigatorResult> + 'a>>
)
pub fn insert_request_irrigator_lambda(
&mut self,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: Matches) -> Pin<Box<dyn Future<Output = IrrigatorResult> + 'a>>
)
Creates a new RequestIrrigator
, which will directly pass calls to
RequestIrrigator::map
to func
.
sourcepub fn with_request_irrigator_lambda(
self,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: Matches) -> Pin<Box<dyn Future<Output = IrrigatorResult> + 'a>>
) -> Self
pub fn with_request_irrigator_lambda(
self,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: Matches) -> Pin<Box<dyn Future<Output = IrrigatorResult> + 'a>>
) -> Self
A chainable version of insert_request_irrigator_lambda
.
sourcepub fn insert_response_irrigator(
&mut self,
irrigator: impl ResponseIrrigator + 'static
)
pub fn insert_response_irrigator(
&mut self,
irrigator: impl ResponseIrrigator + 'static
)
Adds an arbitrary ResponseIrrigator
to the resulting Droughter
.
sourcepub fn with_response_irrigator(
self,
irrigator: impl ResponseIrrigator + 'static
) -> Self
pub fn with_response_irrigator(
self,
irrigator: impl ResponseIrrigator + 'static
) -> Self
A chainable version of insert_response_irrigator
.
sourcepub fn insert_response_irrigator_lambda(
&mut self,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: &'a mut DroughtResult, _: &'a Matches) -> Pin<Box<dyn Future<Output = ()> + 'a>>
)
pub fn insert_response_irrigator_lambda(
&mut self,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: &'a mut DroughtResult, _: &'a Matches) -> Pin<Box<dyn Future<Output = ()> + 'a>>
)
Creates a new Drought
, which will directly pass calls to
Drought::handle
to func
.
sourcepub fn with_response_irrigator_lambda(
self,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: &'a mut DroughtResult, _: &'a Matches) -> Pin<Box<dyn Future<Output = ()> + 'a>>
) -> Self
pub fn with_response_irrigator_lambda(
self,
func: for<'a> fn(_: &'a Vec<String>, _: &'a Vec<String>, _: &'a Request<Vec<u8>>, _: &'a mut DroughtResult, _: &'a Matches) -> Pin<Box<dyn Future<Output = ()> + 'a>>
) -> Self
A chainable version of insert_lambda
.
sourcepub fn build_with_root(self, root: impl Drought + 'static) -> Droughter
pub fn build_with_root(self, root: impl Drought + 'static) -> Droughter
Builds the Droughter
with root
as the index.