pub struct HealthRouterBuilder { /* private fields */ }Expand description
Builder for HealthRouter with a fluent API.
§Example
use loopctl::tool::health::HealthRouterBuilder;
let router = HealthRouterBuilder::new()
.add_fallback("bash", vec!["sh".to_string()])
.add_fallback("edit", vec!["write".to_string(), "sed".to_string()])
.build();
assert_eq!(router.fallbacks_for("edit"), vec!["write", "sed"]);
assert!(router.fallbacks_for("unknown").is_empty());Implementations§
Source§impl HealthRouterBuilder
impl HealthRouterBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty builder.
Equivalent to HealthRouterBuilder::default; every primary
starts with no fallbacks until add_fallback is called.
Sourcepub fn add_fallback(self, primary: &str, alternatives: Vec<String>) -> Self
pub fn add_fallback(self, primary: &str, alternatives: Vec<String>) -> Self
Register a list of fallback tools for a primary tool name.
Replaces any previously-registered fallbacks for primary.
Fallbacks are tried in the order provided when
HealthRouter::resolve_tool walks the list.
Sourcepub fn build(self) -> HealthRouter
pub fn build(self) -> HealthRouter
Build the HealthRouter.
Consumes the builder and freezes the fallback map into an immutable router. The returned router is cheap to clone for sharing across dispatch paths.
Trait Implementations§
Source§impl Clone for HealthRouterBuilder
impl Clone for HealthRouterBuilder
Source§fn clone(&self) -> HealthRouterBuilder
fn clone(&self) -> HealthRouterBuilder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HealthRouterBuilder
impl Debug for HealthRouterBuilder
Source§impl Default for HealthRouterBuilder
impl Default for HealthRouterBuilder
Source§fn default() -> HealthRouterBuilder
fn default() -> HealthRouterBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for HealthRouterBuilder
impl RefUnwindSafe for HealthRouterBuilder
impl Send for HealthRouterBuilder
impl Sync for HealthRouterBuilder
impl Unpin for HealthRouterBuilder
impl UnsafeUnpin for HealthRouterBuilder
impl UnwindSafe for HealthRouterBuilder
Blanket Implementations§
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
Mutably borrows from an owned value. Read more