pub enum Condition {
Show 96 variants
Always,
Never,
Error(String),
Debug(Box<Self>),
If {
if: Box<Self>,
then: Box<Self>,
else: Option<Box<Self>>,
},
Not(Box<Self>),
All(Vec<Self>),
Any(Vec<Self>),
ErrorToSatisfied(Box<Self>),
ErrorToUnsatisfied(Box<Self>),
TryElse {
try: Box<Self>,
else: Box<Self>,
},
PartMap {
part: UrlPart,
map: Map<Self>,
},
StringMap {
value: StringSource,
map: Map<Self>,
},
PartNamedPartitioning {
named_partitioning: StringSource,
part: UrlPart,
map: Map<Self>,
},
StringNamedPartitioning {
named_partitioning: StringSource,
value: StringSource,
map: Map<Self>,
},
FlagIsSet(FlagRef),
FlagIsNotSet(FlagRef),
VarIs {
var: VarRef,
value: StringSource,
},
StringIs {
left: StringSource,
right: StringSource,
},
StringIsSome(StringSource),
StringContains {
value: StringSource,
substring: StringSource,
at: StringLocation,
},
StringMatches {
value: StringSource,
matcher: StringMatcher,
},
UrlIs(StringSource),
SchemeIs(StringSource),
SchemeIsOneOf(Set<String>),
SchemeIsInSet(StringSource),
HostIs(StringSource),
NormalizedHostIs(StringSource),
SubdomainIs(StringSource),
RegDomainIs(StringSource),
DomainIs(StringSource),
DomainMiddleIs(StringSource),
NotDomainSuffixIs(StringSource),
DomainSuffixIs(StringSource),
SubdomainSegmentIs {
index: isize,
value: StringSource,
},
DomainSegmentIs {
index: isize,
value: StringSource,
},
DomainSuffixSegmentIs {
index: isize,
value: StringSource,
},
HostIsOneOf(Set<String>),
NormalizedHostIsOneOf(Set<String>),
SubdomainIsOneOf(Set<String>),
RegDomainIsOneOf(Set<String>),
DomainIsOneOf(Set<String>),
DomainMiddleIsOneOf(Set<String>),
NotDomainSuffixIsOneOf(Set<String>),
DomainSuffixIsOneOf(Set<String>),
SubdomainSegmentIsOneOf {
index: isize,
values: Set<String>,
},
DomainSegmentIsOneOf {
index: isize,
values: Set<String>,
},
DomainSuffixSegmentIsOneOf {
index: isize,
values: Set<String>,
},
HostIsInSet(StringSource),
NormalizedHostIsInSet(StringSource),
SubdomainIsInSet(StringSource),
RegDomainIsInSet(StringSource),
DomainIsInSet(StringSource),
DomainMiddleIsInSet(StringSource),
NotDomainSuffixIsInSet(StringSource),
DomainSuffixIsInSet(StringSource),
SubdomainSegmentIsInSet {
index: isize,
set: StringSource,
},
DomainSegmentIsInSet {
index: isize,
set: StringSource,
},
DomainSuffixSegmentIsInSet {
index: isize,
set: StringSource,
},
UrlHasHost,
HostIsFqdn,
HostIsDomain,
HostIsIp,
HostIsIpv4,
HostIsIpv6,
PathIs(StringSource),
PathIsOneOf(Set<String>),
PathIsInSet(StringSource),
PathStartsWith(StringSource),
FirstNPathSegmentsIs {
n: usize,
value: StringSource,
},
FirstNPathSegmentsIsOneOf {
n: usize,
set: Set<String>,
},
FirstNPathSegmentsIsInSet {
n: usize,
set: StringSource,
},
LastNPathSegmentsIs {
n: usize,
value: StringSource,
},
LastNPathSegmentsIsOneOf {
n: usize,
set: Set<String>,
},
LastNPathSegmentsIsInSet {
n: usize,
set: StringSource,
},
PathHasSegments,
HasPathSegment(isize),
PathSegmentIs {
index: isize,
value: StringSource,
},
PathSegmentIsOneOf {
index: isize,
values: Set<String>,
},
PathSegmentIsInSet {
index: isize,
set: StringSource,
},
QueryIs(StringSource),
HasQueryParam(QueryParamSelector),
QueryParamIs {
param: QueryParamSelector,
value: StringSource,
},
QueryParamIsOneOf {
param: QueryParamSelector,
values: Set<String>,
},
QueryParamIsInSet {
param: QueryParamSelector,
set: StringSource,
},
FragmentIs(StringSource),
FragmentIsOneOf(Set<String>),
FragmentIsInSet(StringSource),
FragmentIsSomeAndStartsWith(StringSource),
PartIs {
part: UrlPart,
value: StringSource,
},
PartContains {
part: UrlPart,
value: StringSource,
at: StringLocation,
},
PartMatches {
part: UrlPart,
matcher: StringMatcher,
},
PartIsOneOf {
part: UrlPart,
values: Set<String>,
},
PartIsInSet {
part: UrlPart,
set: StringSource,
},
Common(CommonCall),
CommonCallArg(StringSource),
}Expand description
Conditions that decide if and when to apply an Action.
-
“*IsOneOf” variants should always be equivalent to a
Self::Anywith a respective “*Is” variant for each value in theSet. -
“*IsInSet” variants should always be equivalent to moving the
SetfromParams::setsto the respective “*IsOneOf” variant.
Variants§
Always
Always satisfied.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com");
assert!(Condition::Always.check(&task_state).unwrap());Never
Never satisfied.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com");
assert!(!Condition::Never.check(&task_state).unwrap());Error(String)
Always returns the error ConditionError::ExplicitError with the included message.
§Errors
Always returns the error ConditionError::ExplicitError.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com");
Condition::Error("...".into()).check(&task_state).unwrap_err();Debug(Box<Self>)
Prints debug info about the contained Self and the current TaskState, then returns its return value.
§Errors
If the call to Self::check returns an error, that error is returned after the debug info is printed.
If
If Self::If::if is satisfied, return the value of Self::If::then.
If Self::If::if is unsatisfied, return the value of Self::If::else.
§Errors
If either call to Self::check returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com");
assert!( Condition::If {r#if: Box::new(Condition::Always), then: Box::new(Condition::Always), r#else: Some(Box::new(Condition::Always))}.check(&task_state).unwrap());
assert!( Condition::If {r#if: Box::new(Condition::Always), then: Box::new(Condition::Always), r#else: Some(Box::new(Condition::Never ))}.check(&task_state).unwrap());
assert!(!Condition::If {r#if: Box::new(Condition::Always), then: Box::new(Condition::Never ), r#else: Some(Box::new(Condition::Always))}.check(&task_state).unwrap());
assert!(!Condition::If {r#if: Box::new(Condition::Always), then: Box::new(Condition::Never ), r#else: Some(Box::new(Condition::Never ))}.check(&task_state).unwrap());
assert!( Condition::If {r#if: Box::new(Condition::Never ), then: Box::new(Condition::Always), r#else: Some(Box::new(Condition::Always))}.check(&task_state).unwrap());
assert!(!Condition::If {r#if: Box::new(Condition::Never ), then: Box::new(Condition::Always), r#else: Some(Box::new(Condition::Never ))}.check(&task_state).unwrap());
assert!( Condition::If {r#if: Box::new(Condition::Never ), then: Box::new(Condition::Never ), r#else: Some(Box::new(Condition::Always))}.check(&task_state).unwrap());
assert!(!Condition::If {r#if: Box::new(Condition::Never ), then: Box::new(Condition::Never ), r#else: Some(Box::new(Condition::Never ))}.check(&task_state).unwrap());Fields
if: Box<Self>The Self to decide between Self::If::then and Self::If::else.
then: Box<Self>The Self to use if Self::If::if is satisfied.
else: Option<Box<Self>>The Self to use if Self::If::if is unsatisfied.
Not(Box<Self>)
Inverts the satisfaction of the contained Self.
§Errors
If the call to Self::check returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state);
assert!(!Condition::Not(Box::new(Condition::Always)).check(&task_state).unwrap());
assert!( Condition::Not(Box::new(Condition::Never )).check(&task_state).unwrap());All(Vec<Self>)
Satisfied if all contained Selfs are satisfied.
§Errors
If any call to Self::check returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state);
assert!(!Condition::All(vec![Condition::Never , Condition::Never ]).check(&task_state).unwrap());
assert!(!Condition::All(vec![Condition::Never , Condition::Always]).check(&task_state).unwrap());
assert!(!Condition::All(vec![Condition::Always, Condition::Never ]).check(&task_state).unwrap());
assert!( Condition::All(vec![Condition::Always, Condition::Always]).check(&task_state).unwrap());Any(Vec<Self>)
Satisfied if any contained Self is satisfied.
§Errors
If any call to Self::check returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state);
assert!(!Condition::Any(vec![Condition::Never , Condition::Never ]).check(&task_state).unwrap());
assert!( Condition::Any(vec![Condition::Never , Condition::Always]).check(&task_state).unwrap());
assert!( Condition::Any(vec![Condition::Always, Condition::Never ]).check(&task_state).unwrap());
assert!( Condition::Any(vec![Condition::Always, Condition::Always]).check(&task_state).unwrap());ErrorToSatisfied(Box<Self>)
Satisfied if the contained Self is satisfied or errors.
ErrorToUnsatisfied(Box<Self>)
TryElse
If Self::TryElse::try’s call to Self::check returns an error, return the value of Self::TryElse::else.
§Errors
If both calls to Self::check return errors, both errors are returned in a ConditionError::TryElseError.
Fields
else: Box<Self>The Self to try if Self::TryElse::try returns an error.
PartMap
Gets the value specified by Self::PartMap::part, indexes Self::PartMap::map, and returns the value of the returned Self.
If the call to Map::get returns None, fails.
§Errors
If the call to Self::check returns an error, that error is returned.
Fields
part: UrlPartThe UrlPart to index Self::PartMap::map with.
map: Map<Self>The Map to index with Self::PartMap::part.
StringMap
Gets the string specified by Self::StringMap::value, indexes Self::StringMap::map, and returns the value of the returned Self.
If the call to Map::get returns None, fails.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to Self::check returns an error, that error is returned.
Fields
value: StringSourceThe StringSource to index Self::StringMap::map with.
map: Map<Self>The Map to index with Self::StringMap::value.
PartNamedPartitioning
Gets the name of the partition Self::PartNamedPartitioning::part is in in the specified NamedPartitioning, indexes Self::PartNamedPartitioning::map with the partition name, and if the Map has a Self there, applies it.
§Errors
If either call to StringSource::get returns an error, that error is returned.
If either call to StringSource::get returns None, returns the error Condition.
If the NamedPartitioning isn’t found, returns the error ConditionError::NamedPartitioningNotFound.
If the call to Self::check returns an error, that error is returned.
Fields
named_partitioning: StringSourceThe NamedPartitioning to search in.
part: UrlPartThe UrlPart whose value to find in the NamedPartitioning.
StringNamedPartitioning
Gets the name of the partition Self::StringNamedPartitioning::value is in in the specified NamedPartitioning, indexes Self::StringNamedPartitioning::map with the partition name, and if the Map has a Self there, applies it.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error Condition.
If the NamedPartitioning isn’t found, returns the error ConditionError::NamedPartitioningNotFound.
If the call to Self::check returns an error, that error is returned.
Fields
named_partitioning: StringSourceThe NamedPartitioning to search in.
value: StringSourceThe StringSource whose value to find in the NamedPartitioning.
FlagIsSet(FlagRef)
Satisfied if the specified flag is set.
§Errors
If the call to FlagRef::get returns an error, that error is returned.
FlagIsNotSet(FlagRef)
Satisfied if the specified flag is not set.
§Errors
If the call to FlagRef::get returns an error, that error is returned.
VarIs
Satisfied if Self::VarIs::var is Self::VarIs::value.
§Errors
If the call to VarRef::get returns an error, that error is returned.
If the call to StringSource::get returns an error, that error is returned.
Fields
value: StringSourceThe value to check if Self::VarIs::var is.
StringIs
Satisfied if Self::StringIs::left is Self::StringIs::right.
§Errors
If either call to StringSource::get returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state);
assert!( Condition::StringIs {left: "a".into(), right: "a".into()}.check(&task_state).unwrap());
assert!(!Condition::StringIs {left: "a".into(), right: "b".into()}.check(&task_state).unwrap());Fields
left: StringSourceThe left hand side of the equality check.
right: StringSourceThe right hand side of the equality check.
StringIsSome(StringSource)
Satisfied if the specified StringSource is Some.
§Errors
If the call to StringSource::get returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state);
assert!( Condition::StringIsSome("abc" .into()).check(&task_state).unwrap());
assert!(!Condition::StringIsSome(None::<&str>.into()).check(&task_state).unwrap());StringContains
Satisfied if Self::StringContains::value contains Self::StringContains::substring at Self::StringContains::value.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error Condition.
If the call to StringLocation::check returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state);
assert!(Condition::StringContains {value: "abc".into(), substring: "b".into(), at: StringLocation::Anywhere}.check(&task_state).unwrap());Fields
value: StringSourceThe value to search for Self::StringContains::substring.
substring: StringSourceThe value to search for inside Self::StringContains::value.
at: StringLocationWhere in Self::StringContains::value to search for Self::StringContains::substring.
Defaults to StringLocation::Anywhere.
StringMatches
Satisfied if Self::StringMatches::value satisfies Self::StringMatches::matcher.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error Condition.
If the call to StringMatcher::check returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state);
assert!(Condition::StringMatches {value: "abc".into(), matcher: StringMatcher::Always}.check(&task_state).unwrap());Fields
value: StringSourceThe value to check the value of.
matcher: StringMatcherThe matcher to check if Self::StringMatches::value satisfies.
UrlIs(StringSource)
Satisfied if the URL is the specified string.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com");
assert!(Condition::UrlIs("https://example.com/".into()).check(&task_state).unwrap());SchemeIs(StringSource)
Satisfied if the value of Url::scheme is equal to the specified string.
§Errors
If the call to StringSource::get returns an error, that error is returned.
SchemeIsOneOf(Set<String>)
Satisfied if the Url::scheme is in the specified Set.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::SchemeIsOneOf(
[
"http".to_string(),
"https".to_string()
].into()
);
tsv!(ts, url = "http://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com"); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "other://example.com"); assert!(!condition.check(&ts).unwrap());SchemeIsInSet(StringSource)
Satisfied if the Url::scheme is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
HostIs(StringSource)
Satisfied if the value of Url::host is equal to the specified string.
§Errors
If the call to StringSource::get returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::HostIs("example.com".into());
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());NormalizedHostIs(StringSource)
Satisfied if the BetterUrl::normalized_host is equal to the specified string.
§Errors
If the call to StringSource::get returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::NormalizedHostIs("example.com".into());
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());SubdomainIs(StringSource)
Satisfied if the value of BetterUrl::subdomain is equal to the specified string.
§Errors
If the call to StringSource::get returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::SubdomainIs("www".into());
tsv!(ts, url = "https://example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());RegDomainIs(StringSource)
Satisfied if the value of BetterUrl::reg_domain is equal to the specified string.
§Errors
If the call to StringSource::get returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::RegDomainIs("example.com".into());
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());DomainIs(StringSource)
Satisfied if the value of BetterUrl::domain is equal to the specified string.
§Errors
If the call to StringSource::get returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::DomainIs("example.com".into());
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());DomainMiddleIs(StringSource)
Satisfied if the value of BetterUrl::domain_middle is equal to the specified string.
§Errors
If the call to StringSource::get returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::DomainMiddleIs("example".into());
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());NotDomainSuffixIs(StringSource)
Satisfied if the value of BetterUrl::not_domain_suffix is equal to the specified string.
§Errors
If the call to StringSource::get returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::NotDomainSuffixIs("www.example".into());
tsv!(ts, url = "https://example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());DomainSuffixIs(StringSource)
Satisfied if the value of BetterUrl::domain_suffix is equal to the specified string.
§Errors
If the call to StringSource::get returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::DomainSuffixIs("com".into());
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());SubdomainSegmentIs
Satisfied if the BetterUrl::subdomain_segment is the specified value.
§Errors
If the call to StringSource::get returns an error, that error is returned.
DomainSegmentIs
Satisfied if the BetterUrl::domain_segment is the specified value.
§Errors
If the call to StringSource::get returns an error, that error is returned.
DomainSuffixSegmentIs
Satisfied if the BetterUrl::domain_suffix_segment is the specified value.
§Errors
If the call to StringSource::get returns an error, that error is returned.
HostIsOneOf(Set<String>)
Satisfied if the Url::host is contained in the specified Set.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::HostIsOneOf(
[
"example.com".to_string(),
"www.example.com".to_string()
].into()
);
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());NormalizedHostIsOneOf(Set<String>)
Satisfied if the BetterUrl::normalized_host is in the specified Set.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::NormalizedHostIsOneOf(
[
"example.com".to_string()
].into()
);
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());SubdomainIsOneOf(Set<String>)
Satisfied if the BetterUrl::subdomain is contained in the specified Set.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::SubdomainIsOneOf(
[
"www".to_string(),
"abc".to_string()
].into()
);
tsv!(ts, url = "https://example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());RegDomainIsOneOf(Set<String>)
Satisfied if the BetterUrl::reg_domain is in the specified Set.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::RegDomainIsOneOf(
[
"example.com".to_string()
].into()
);
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());DomainIsOneOf(Set<String>)
Satisfied if the BetterUrl::domain is in the specified Set.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::DomainIsOneOf(
[
"example.com".to_string(),
"abc.example.com".to_string()
].into()
);
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());DomainMiddleIsOneOf(Set<String>)
Satisfied if the BetterUrl::domain_middle is in the specified Set.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::DomainMiddleIsOneOf(
[
"example".to_string()
].into()
);
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());NotDomainSuffixIsOneOf(Set<String>)
Satisfied if the BetterUrl::not_domain_suffix is in the specified Set.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::NotDomainSuffixIsOneOf(
[
"example".to_string(),
"abc.example".to_string()
].into()
);
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());DomainSuffixIsOneOf(Set<String>)
Satisfied if the BetterUrl::domain_suffix is in the specified Set.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
let condition = Condition::DomainSuffixIsOneOf(
[
"com".to_string()
].into()
);
tsv!(ts, url = "https://example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!( condition.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!condition.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!condition.check(&ts).unwrap());SubdomainSegmentIsOneOf
Satisfied if the BetterUrl::subdomain_segment is in the specified Set.
DomainSegmentIsOneOf
Satisfied if the BetterUrl::domain_segment is in the specified Set.
DomainSuffixSegmentIsOneOf
Satisfied if the BetterUrl::domain_suffix_segment is in the specified Set.
HostIsInSet(StringSource)
Satisfied if the Url::host_str is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
NormalizedHostIsInSet(StringSource)
Satisfied if the BetterUrl::normalized_host is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
SubdomainIsInSet(StringSource)
Satisfied if the BetterUrl::subdomain is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
RegDomainIsInSet(StringSource)
Satisfied if the BetterUrl::reg_domain is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
DomainIsInSet(StringSource)
Satisfied if the BetterUrl::domain is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
DomainMiddleIsInSet(StringSource)
Satisfied if the BetterUrl::domain_middle is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
NotDomainSuffixIsInSet(StringSource)
Satisfied if the BetterUrl::not_domain_suffix is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
DomainSuffixIsInSet(StringSource)
Satisfied if the BetterUrl::domain_suffix is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
SubdomainSegmentIsInSet
Satisfied if the BetterUrl::subdomain_segment is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
Fields
set: StringSourceThe name of the Params::sets Set to check it with.
DomainSegmentIsInSet
Satisfied if the BetterUrl::domain_segment is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
Fields
set: StringSourceThe name of the Params::sets Set to check it with.
DomainSuffixSegmentIsInSet
Satisfied if the BetterUrl::domain_suffix_segment is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
Fields
set: StringSourceThe name of the Params::sets Set to check it with.
UrlHasHost
Satisfied if the Url::host is Some.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
tsv!(ts, url = "https://example.com" ); assert!(Condition::UrlHasHost.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!(Condition::UrlHasHost.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!(Condition::UrlHasHost.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!(Condition::UrlHasHost.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(Condition::UrlHasHost.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!(Condition::UrlHasHost.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(Condition::UrlHasHost.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(Condition::UrlHasHost.check(&ts).unwrap());HostIsFqdn
Satisfied if the URL’s host is a fully qualified domain name.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
tsv!(ts, url = "https://example.com" ); assert!(!Condition::HostIsFqdn.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( Condition::HostIsFqdn.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!(!Condition::HostIsFqdn.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( Condition::HostIsFqdn.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(!Condition::HostIsFqdn.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!( Condition::HostIsFqdn.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!Condition::HostIsFqdn.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!Condition::HostIsFqdn.check(&ts).unwrap());HostIsDomain
Satisfied if the URL’s host is a domain.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
tsv!(ts, url = "https://example.com" ); assert!( Condition::HostIsDomain.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!( Condition::HostIsDomain.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!( Condition::HostIsDomain.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!( Condition::HostIsDomain.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!( Condition::HostIsDomain.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!( Condition::HostIsDomain.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!Condition::HostIsDomain.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!Condition::HostIsDomain.check(&ts).unwrap());HostIsIp
Satisfied if the URL’s host is an IP address.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
tsv!(ts, url = "https://example.com" ); assert!(!Condition::HostIsIp.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!(!Condition::HostIsIp.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!(!Condition::HostIsIp.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!(!Condition::HostIsIp.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(!Condition::HostIsIp.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!(!Condition::HostIsIp.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!( Condition::HostIsIp.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!( Condition::HostIsIp.check(&ts).unwrap());HostIsIpv4
Satisfied if the URL’s host is an IPv4 address.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
tsv!(ts, url = "https://example.com" ); assert!(!Condition::HostIsIpv4.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!(!Condition::HostIsIpv4.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!(!Condition::HostIsIpv4.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!(!Condition::HostIsIpv4.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(!Condition::HostIsIpv4.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!(!Condition::HostIsIpv4.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!( Condition::HostIsIpv4.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!(!Condition::HostIsIpv4.check(&ts).unwrap());HostIsIpv6
Satisfied if the URL’s host is an IPv6 address.
§Examples
use url_cleaner_engine::types::*;
use url_cleaner_engine::task_state_view as tsv;
tsv!(ts, url = "https://example.com" ); assert!(!Condition::HostIsIpv6.check(&ts).unwrap());
tsv!(ts, url = "https://example.com." ); assert!(!Condition::HostIsIpv6.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com" ); assert!(!Condition::HostIsIpv6.check(&ts).unwrap());
tsv!(ts, url = "https://www.example.com."); assert!(!Condition::HostIsIpv6.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com" ); assert!(!Condition::HostIsIpv6.check(&ts).unwrap());
tsv!(ts, url = "https://abc.example.com."); assert!(!Condition::HostIsIpv6.check(&ts).unwrap());
tsv!(ts, url = "https://127.0.0.1" ); assert!(!Condition::HostIsIpv6.check(&ts).unwrap());
tsv!(ts, url = "https://[::1]" ); assert!( Condition::HostIsIpv6.check(&ts).unwrap());PathIs(StringSource)
Satisfied if the Url::path is the specified value.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com/a/b/c");
assert!( Condition::PathIs("/a/b/c" .into()).check(&task_state).unwrap());
assert!(!Condition::PathIs("/a/b/c/".into()).check(&task_state).unwrap());PathIsOneOf(Set<String>)
PathIsInSet(StringSource)
Satisfied if the Url::path is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
PathStartsWith(StringSource)
Satisfied if the Url::path starts with the specified value.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com/a/b/c");
assert!( Condition::PathStartsWith("" .into()).check(&task_state).unwrap());
assert!( Condition::PathStartsWith("/" .into()).check(&task_state).unwrap());
assert!( Condition::PathStartsWith("/a" .into()).check(&task_state).unwrap());
assert!( Condition::PathStartsWith("/a/" .into()).check(&task_state).unwrap());
assert!( Condition::PathStartsWith("/a/b" .into()).check(&task_state).unwrap());
assert!( Condition::PathStartsWith("/a/b/" .into()).check(&task_state).unwrap());
assert!( Condition::PathStartsWith("/a/b/c" .into()).check(&task_state).unwrap());
assert!(!Condition::PathStartsWith("/a/b/c/" .into()).check(&task_state).unwrap());
assert!(!Condition::PathStartsWith("/a/b/c/d".into()).check(&task_state).unwrap());FirstNPathSegmentsIs
§Errors
If the call to BetterUrl::first_n_path_segments returns an error, that error is returned.
If the call to StringSource::get returns an error, that error is returned.
Fields
value: StringSourceThe value to check if it’s equal to.
FirstNPathSegmentsIsOneOf
§Errors
If the call to BetterUrl::first_n_path_segments returns an error, that error is returned.
FirstNPathSegmentsIsInSet
§Errors
If the call to BetterUrl::first_n_path_segments returns an error, that error is returned.
If the call to StringSource::get returns an error, that error is returned.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
Fields
set: StringSourceThe name of the Params::sets Set to check if it’s in.
LastNPathSegmentsIs
§Errors
If the call to BetterUrl::last_n_path_segments returns an error, that error is returned.
If the call to StringSource::get returns an error, that error is returned.
Fields
value: StringSourceThe value to check if it’s equal to.
LastNPathSegmentsIsOneOf
§Errors
If the call to BetterUrl::last_n_path_segments returns an error, that error is returned.
LastNPathSegmentsIsInSet
§Errors
If the call to BetterUrl::last_n_path_segments returns an error, that error is returned.
If the call to StringSource::get returns an error, that error is returned.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
Fields
set: StringSourceThe name of the Params::sets Set to check if it’s in.
PathHasSegments
Satisfied if the Url::path has segments.
HasPathSegment(isize)
Satisfied if the call to BetterUrl::path_segment returns Ok of Some.
Unsatisfied if BetterUrl::path_segment returns Err because not having path segments means it doesn’t have the specified path segment.
PathSegmentIs
Satisfied if the BetterUrl::path_segment is the specified value.
§Errors
If the call to BetterUrl::path_segment returns an error, that error is returned.
PathSegmentIsOneOf
Satisfied if the BetterUrl::path_segment is in the specified Set.
§Errors
If the call to BetterUrl::path_segment returns an error, that error is returned.
PathSegmentIsInSet
Satisfied if the BetterUrl::path_segment is in the specified Params::sets Set.
§Errors
If the call to BetterUrl::path_segment returns an error, that error is returned.
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
Fields
set: StringSourceThe name of the Params::sets Set to check it with.
QueryIs(StringSource)
Satisfied if the Url::query is the specified value.
HasQueryParam(QueryParamSelector)
Satisfied if the URL’ has a query query and has a matching query parameter.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com?a=2&b=3");
assert!( Condition::HasQueryParam("a".into()).check(&task_state).unwrap());
assert!( Condition::HasQueryParam("b".into()).check(&task_state).unwrap());
assert!(!Condition::HasQueryParam("c".into()).check(&task_state).unwrap());QueryParamIs
Satisfied if the BetterUrl::query_param is the specified value.
Fields
param: QueryParamSelectorThe query param to check.
value: StringSourceThe value to compare it to.
QueryParamIsOneOf
Satisfied if the BetterUrl::query_param is in the specified Set.
Fields
param: QueryParamSelectorThe query param to check.
QueryParamIsInSet
Satisfied if the BetterUrl::query_param is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
Fields
param: QueryParamSelectorThe query param to check.
set: StringSourceThe name of the Params::sets Set to check it with.
FragmentIs(StringSource)
Satisfied if the Url::fragment is the specified value.
FragmentIsOneOf(Set<String>)
Satisfied if the Url::fragment is in the specified Set.
FragmentIsInSet(StringSource)
Satisfied if the Url::fragment is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
FragmentIsSomeAndStartsWith(StringSource)
Satisfied if the Url::fragment is Some and starts with the specified value.
§Errors
If the call to StringSource::get returns an error, that error is returned.
PartIs
Satisfied if the value of Self::PartIs::part is the same as the value of Self::PartIs::value.
§Errors
If the call to StringSource::get returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com/abc?a=2");
assert!(Condition::PartIs {part: UrlPart::Host , value: "example.com".into()}.check(&task_state).unwrap());
assert!(Condition::PartIs {part: UrlPart::Path , value: "/abc" .into()}.check(&task_state).unwrap());
assert!(Condition::PartIs {part: UrlPart::Query , value: "a=2" .into()}.check(&task_state).unwrap());
assert!(Condition::PartIs {part: UrlPart::QueryParam("a".into()), value: "2" .into()}.check(&task_state).unwrap());Fields
value: StringSourceThe StringSource to compare Self::PartIs::value with.
PartContains
Satisfied if Self::PartContains::part contains Self::PartContains::value at Self::PartContains::at.
§Errors
If the call to UrlPart::get returns None, returns the error Condition.
If the call to StringSource::get returns None, returns the error Condition.
If the call to StringLocation::check returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com/abc");
assert!(Condition::PartContains {part: UrlPart::Path, value: "/ab".into(), at: StringLocation::Start}.check(&task_state).unwrap());
Condition::PartContains {part: UrlPart::Fragment, value: "".into(), at: StringLocation::Start}.check(&task_state).unwrap_err();Fields
value: StringSourceThe value to look for.
at: StringLocationWhere to look in Self::PartContains::part for Self::PartContains::value.
Defaults to StringLocation::Anywhere.
PartMatches
Satisfied if Self::PartMatches::part satisfies Self::PartMatches::matcher.
§Errors
If the call to UrlPart::get returns None, returns the error Condition.
If the call to StringMatcher::check returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com/abc");
assert!(Condition::PartMatches {part: UrlPart::Path , matcher: StringMatcher::Always}.check(&task_state).unwrap());
assert!(Condition::PartMatches {part: UrlPart::Fragment, matcher: StringMatcher::Always}.check(&task_state).unwrap());Fields
matcher: StringMatcherThe matcher to test Self::PartMatches::part with.
PartIsOneOf
Satisfied if Self::PartIsOneOf::part is in Self::PartIsOneOf::values.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, url = "https://example.com/abc");
assert!(Condition::PartIsOneOf {part: UrlPart::Path , values: [Some("/abc".into()), None].into()}.check(&task_state).unwrap());
assert!(Condition::PartIsOneOf {part: UrlPart::Fragment, values: [Some("/abc".into()), None].into()}.check(&task_state).unwrap());Fields
values: Set<String>The set of values to check if Self::PartIsOneOf::part is one of.
PartIsInSet
Satisfied if Self::PartIsInSet is in the specified Params::sets Set.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error ConditionError.
If the Set isn’t found, returns the error ConditionError::SetNotFound.
Fields
set: StringSourceThe name of the Params::sets Set to check it with.
Common(CommonCall)
Satisfied if the specified Self from TaskStateView::commons’s Commons::conditions is.
§Errors
If the call to StringSource::get returns an error, that error is returned.
If the call to StringSource::get returns None, returns the error Condition.
If the common Self isn’t found, returns the error ConditionError::CommonConditionNotFound.
If the call to CommonCallArgsSource::build returns an error, that error is returned.
If the call to Self::check returns an error, that error is returned.
§Examples
use url_cleaner_engine::types::*;
url_cleaner_engine::task_state_view!(task_state, commons = Commons {
conditions: [("abc".into(), Condition::Always)].into(),
..Default::default()
});
assert!(Condition::Common(CommonCall {name: Box::new("abc".into()), args: Default::default()}).check(&task_state).unwrap());CommonCallArg(StringSource)
Gets a Self from TaskStateView::common_args’s CommonCallArgs::conditions and applies it.
§Errors
If TaskStateView::common_args is None, returns the error ConditionError::NotInCommonContext.
If the common call arg Self isn’t found, returns the error ConditionError::CommonCallArgConditionNotFound.
If the call to Self::check returns an error, that error is returned.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Condition
impl<'de> Deserialize<'de> for Condition
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>,
impl Eq for Condition
impl StructuralPartialEq for Condition
Auto Trait Implementations§
impl !Freeze for Condition
impl RefUnwindSafe for Condition
impl Send for Condition
impl Sync for Condition
impl Unpin for Condition
impl UnwindSafe for Condition
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read more