Condition

Enum Condition 

Source
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::Any with a respective “*Is” variant for each value in the Set.

  • “*IsInSet” variants should always be equivalent to moving the Set from Params::sets to 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>)

Satisfied if the contained Self is satisfied.

Unsatisfied if the contained Self errors.

§

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

§try: Box<Self>

The Self to try first.

§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: UrlPart

The 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

§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: StringSource

The NamedPartitioning to search in.

§part: UrlPart

The UrlPart whose value to find in the NamedPartitioning.

§map: Map<Self>

The Map to index.

§

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: StringSource

The NamedPartitioning to search in.

§value: StringSource

The StringSource whose value to find in the NamedPartitioning.

§map: Map<Self>

The Map to index.

§

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

§var: VarRef

The var to check the value of.

§value: StringSource

The 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: StringSource

The left hand side of the equality check.

§right: StringSource

The 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: StringSource

The value to search for Self::StringContains::substring.

§substring: StringSource

The value to search for inside Self::StringContains::value.

§

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: StringSource

The value to check the value of.

§matcher: StringMatcher

The 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.

Fields

§index: isize

The segment to check.

§value: StringSource

The value to compare it to.

§

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.

Fields

§index: isize

The segment to check.

§value: StringSource

The value to compare it to.

§

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.

Fields

§index: isize

The segment to check.

§value: StringSource

The value to compare it to.

§

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.

Fields

§index: isize

The segment to check.

§values: Set<String>

The set to check it with.

§

DomainSegmentIsOneOf

Satisfied if the BetterUrl::domain_segment is in the specified Set.

Fields

§index: isize

The segment to check.

§values: Set<String>

The set to check it with.

§

DomainSuffixSegmentIsOneOf

Satisfied if the BetterUrl::domain_suffix_segment is in the specified Set.

Fields

§index: isize

The segment to check.

§values: Set<String>

The set to check it with.

§

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

§index: isize

The segment to check.

§set: StringSource

The 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

§index: isize

The segment to check.

§set: StringSource

The 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

§index: isize

The segment to check.

§set: StringSource

The 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>)

Satisfied if the Url::path is in the specified Set.

§

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

§n: usize

The number of path segments to get.

§value: StringSource

The 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.

Fields

§n: usize

The number of path segments to get.

§set: Set<String>

The Set to check if it’s in.

§

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

§n: usize

The number of path segments to get.

§set: StringSource

The 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

§n: usize

The number of path segments to get.

§value: StringSource

The 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.

Fields

§n: usize

The number of path segments to get.

§set: Set<String>

The Set to check if it’s in.

§

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

§n: usize

The number of path segments to get.

§set: StringSource

The 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.

Fields

§index: isize

The segment to check.

§value: StringSource

The value to compare it to.

§

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.

Fields

§index: isize

The segment to check.

§values: Set<String>

The set to check it with.

§

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

§index: isize

The segment to check.

§set: StringSource

The 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: QueryParamSelector

The query param to check.

§value: StringSource

The value to compare it to.

§

QueryParamIsOneOf

Satisfied if the BetterUrl::query_param is in the specified Set.

Fields

§param: QueryParamSelector

The query param to check.

§values: Set<String>

The set to check it with.

§

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: QueryParamSelector

The query param to check.

§set: StringSource

The 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

§part: UrlPart

The UrlPart to get.

§value: StringSource

The 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

§part: UrlPart

The part to look in.

§value: StringSource

The value to look for.

§

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

§part: UrlPart

The part to match the value of.

§matcher: StringMatcher

The 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

§part: UrlPart

The part to check the value of.

§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

§part: UrlPart

The part to check the value of.

§set: StringSource

The 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§

Source§

impl Condition

Source

pub fn check( &self, task_state: &TaskStateView<'_>, ) -> Result<bool, ConditionError>

If the specified variant of Self is satisfied, return true.

If the specified variant of Self is unsatisfied, return false.

§Errors

See each variant of Self for when each variant returns an error.

Trait Implementations§

Source§

impl Clone for Condition

Source§

fn clone(&self) -> Condition

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Condition

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Condition

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Condition

Source§

fn eq(&self, other: &Condition) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Condition

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Condition

Source§

impl StructuralPartialEq for Condition

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AggregateExpressionMethods for T

Source§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
Source§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
Source§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
Source§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WindowExpressionMethods for T

Source§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
Source§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
Source§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
Source§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
Source§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,