pub struct RuleSet {
pub prefix: Option<Prefix>,
pub default: Option<DefaultRespond>,
pub guard: Option<Guard>,
pub rules: Vec<Rule>,
pub strategy: Option<Strategy>,
pub file_path: String,
pub round_robin_counter: Arc<AtomicUsize>,
}Fields§
§prefix: Option<Prefix>§default: Option<DefaultRespond>§guard: Option<Guard>§rules: Vec<Rule>§strategy: Option<Strategy>Per-rule-set strategy override (RFC 025).
When Some, this strategy is used instead of the service-level one.
When None, the service-level strategy applies.
file_path: String§round_robin_counter: Arc<AtomicUsize>Per-rule-set round-robin counter. Shared across clones via Arc.
Implementations§
Source§impl RuleSet
impl RuleSet
Sourcepub fn new(
rule_set_file_path: &str,
current_dir_to_config_dir_relative_path: &str,
rule_set_idx: usize,
) -> RoutingResult<Self>
pub fn new( rule_set_file_path: &str, current_dir_to_config_dir_relative_path: &str, rule_set_idx: usize, ) -> RoutingResult<Self>
Load a rule set from a TOML file on disk.
§Why errors are typed and not panics
In 4.6.x this used expect + panic!, so a missing or malformed
rule set aborted the process. Because rule sets are edited
frequently during development, those panics were a common papercut.
Now any failure becomes an RoutingError::RuleSetRead / ::RuleSetParse
that the caller can surface cleanly.
Sourcepub fn find_matched(
&self,
parsed_request: &ParsedRequest,
strategy: Option<&Strategy>,
rule_set_idx: usize,
) -> Option<Respond>
pub fn find_matched( &self, parsed_request: &ParsedRequest, strategy: Option<&Strategy>, rule_set_idx: usize, ) -> Option<Respond>
find rule matching request and return its respond content
Sourcepub fn dir_prefix(&self) -> String
pub fn dir_prefix(&self) -> String
dir_prefix as string possibly as empty
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RuleSet
impl<'de> Deserialize<'de> for RuleSet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for RuleSet
impl RefUnwindSafe for RuleSet
impl Send for RuleSet
impl Sync for RuleSet
impl Unpin for RuleSet
impl UnsafeUnpin for RuleSet
impl UnwindSafe for RuleSet
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