Rule

Struct Rule 

Source
#[non_exhaustive]
pub struct Rule { pub condition: Option<Condition>, pub action: Option<Action>, /* private fields */ }
Expand description

A rule is a condition-action pair

  • A condition defines when a rule is to be triggered.
  • An action specifies what occurs on that trigger. Currently rules only work for controls with SOLUTION_TYPE_SEARCH.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§condition: Option<Condition>

Required. The condition that triggers the rule. If the condition is empty, the rule will always apply.

§action: Option<Action>

An action must be provided.

Implementations§

Source§

impl Rule

Source

pub fn new() -> Self

Source

pub fn set_condition<T>(self, v: T) -> Self
where T: Into<Condition>,

Sets the value of condition.

§Example
use google_cloud_retail_v2::model::Condition;
let x = Rule::new().set_condition(Condition::default()/* use setters */);
Source

pub fn set_or_clear_condition<T>(self, v: Option<T>) -> Self
where T: Into<Condition>,

Sets or clears the value of condition.

§Example
use google_cloud_retail_v2::model::Condition;
let x = Rule::new().set_or_clear_condition(Some(Condition::default()/* use setters */));
let x = Rule::new().set_or_clear_condition(None::<Condition>);
Source

pub fn set_action<T: Into<Option<Action>>>(self, v: T) -> Self

Sets the value of action.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::BoostAction;
let x = Rule::new().set_action(Some(
    google_cloud_retail_v2::model::rule::Action::BoostAction(BoostAction::default().into())));
Source

pub fn boost_action(&self) -> Option<&Box<BoostAction>>

The value of action if it holds a BoostAction, None if the field is not set or holds a different branch.

Source

pub fn set_boost_action<T: Into<Box<BoostAction>>>(self, v: T) -> Self

Sets the value of action to hold a BoostAction.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::BoostAction;
let x = Rule::new().set_boost_action(BoostAction::default()/* use setters */);
assert!(x.boost_action().is_some());
assert!(x.redirect_action().is_none());
assert!(x.oneway_synonyms_action().is_none());
assert!(x.do_not_associate_action().is_none());
assert!(x.replacement_action().is_none());
assert!(x.ignore_action().is_none());
assert!(x.filter_action().is_none());
assert!(x.twoway_synonyms_action().is_none());
assert!(x.force_return_facet_action().is_none());
assert!(x.remove_facet_action().is_none());
assert!(x.pin_action().is_none());
Source

pub fn redirect_action(&self) -> Option<&Box<RedirectAction>>

The value of action if it holds a RedirectAction, None if the field is not set or holds a different branch.

Source

pub fn set_redirect_action<T: Into<Box<RedirectAction>>>(self, v: T) -> Self

Sets the value of action to hold a RedirectAction.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::RedirectAction;
let x = Rule::new().set_redirect_action(RedirectAction::default()/* use setters */);
assert!(x.redirect_action().is_some());
assert!(x.boost_action().is_none());
assert!(x.oneway_synonyms_action().is_none());
assert!(x.do_not_associate_action().is_none());
assert!(x.replacement_action().is_none());
assert!(x.ignore_action().is_none());
assert!(x.filter_action().is_none());
assert!(x.twoway_synonyms_action().is_none());
assert!(x.force_return_facet_action().is_none());
assert!(x.remove_facet_action().is_none());
assert!(x.pin_action().is_none());
Source

pub fn oneway_synonyms_action(&self) -> Option<&Box<OnewaySynonymsAction>>

The value of action if it holds a OnewaySynonymsAction, None if the field is not set or holds a different branch.

Source

pub fn set_oneway_synonyms_action<T: Into<Box<OnewaySynonymsAction>>>( self, v: T, ) -> Self

Sets the value of action to hold a OnewaySynonymsAction.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::OnewaySynonymsAction;
let x = Rule::new().set_oneway_synonyms_action(OnewaySynonymsAction::default()/* use setters */);
assert!(x.oneway_synonyms_action().is_some());
assert!(x.boost_action().is_none());
assert!(x.redirect_action().is_none());
assert!(x.do_not_associate_action().is_none());
assert!(x.replacement_action().is_none());
assert!(x.ignore_action().is_none());
assert!(x.filter_action().is_none());
assert!(x.twoway_synonyms_action().is_none());
assert!(x.force_return_facet_action().is_none());
assert!(x.remove_facet_action().is_none());
assert!(x.pin_action().is_none());
Source

pub fn do_not_associate_action(&self) -> Option<&Box<DoNotAssociateAction>>

The value of action if it holds a DoNotAssociateAction, None if the field is not set or holds a different branch.

Source

pub fn set_do_not_associate_action<T: Into<Box<DoNotAssociateAction>>>( self, v: T, ) -> Self

Sets the value of action to hold a DoNotAssociateAction.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::DoNotAssociateAction;
let x = Rule::new().set_do_not_associate_action(DoNotAssociateAction::default()/* use setters */);
assert!(x.do_not_associate_action().is_some());
assert!(x.boost_action().is_none());
assert!(x.redirect_action().is_none());
assert!(x.oneway_synonyms_action().is_none());
assert!(x.replacement_action().is_none());
assert!(x.ignore_action().is_none());
assert!(x.filter_action().is_none());
assert!(x.twoway_synonyms_action().is_none());
assert!(x.force_return_facet_action().is_none());
assert!(x.remove_facet_action().is_none());
assert!(x.pin_action().is_none());
Source

pub fn replacement_action(&self) -> Option<&Box<ReplacementAction>>

The value of action if it holds a ReplacementAction, None if the field is not set or holds a different branch.

Source

pub fn set_replacement_action<T: Into<Box<ReplacementAction>>>( self, v: T, ) -> Self

Sets the value of action to hold a ReplacementAction.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::ReplacementAction;
let x = Rule::new().set_replacement_action(ReplacementAction::default()/* use setters */);
assert!(x.replacement_action().is_some());
assert!(x.boost_action().is_none());
assert!(x.redirect_action().is_none());
assert!(x.oneway_synonyms_action().is_none());
assert!(x.do_not_associate_action().is_none());
assert!(x.ignore_action().is_none());
assert!(x.filter_action().is_none());
assert!(x.twoway_synonyms_action().is_none());
assert!(x.force_return_facet_action().is_none());
assert!(x.remove_facet_action().is_none());
assert!(x.pin_action().is_none());
Source

pub fn ignore_action(&self) -> Option<&Box<IgnoreAction>>

The value of action if it holds a IgnoreAction, None if the field is not set or holds a different branch.

Source

pub fn set_ignore_action<T: Into<Box<IgnoreAction>>>(self, v: T) -> Self

Sets the value of action to hold a IgnoreAction.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::IgnoreAction;
let x = Rule::new().set_ignore_action(IgnoreAction::default()/* use setters */);
assert!(x.ignore_action().is_some());
assert!(x.boost_action().is_none());
assert!(x.redirect_action().is_none());
assert!(x.oneway_synonyms_action().is_none());
assert!(x.do_not_associate_action().is_none());
assert!(x.replacement_action().is_none());
assert!(x.filter_action().is_none());
assert!(x.twoway_synonyms_action().is_none());
assert!(x.force_return_facet_action().is_none());
assert!(x.remove_facet_action().is_none());
assert!(x.pin_action().is_none());
Source

pub fn filter_action(&self) -> Option<&Box<FilterAction>>

The value of action if it holds a FilterAction, None if the field is not set or holds a different branch.

Source

pub fn set_filter_action<T: Into<Box<FilterAction>>>(self, v: T) -> Self

Sets the value of action to hold a FilterAction.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::FilterAction;
let x = Rule::new().set_filter_action(FilterAction::default()/* use setters */);
assert!(x.filter_action().is_some());
assert!(x.boost_action().is_none());
assert!(x.redirect_action().is_none());
assert!(x.oneway_synonyms_action().is_none());
assert!(x.do_not_associate_action().is_none());
assert!(x.replacement_action().is_none());
assert!(x.ignore_action().is_none());
assert!(x.twoway_synonyms_action().is_none());
assert!(x.force_return_facet_action().is_none());
assert!(x.remove_facet_action().is_none());
assert!(x.pin_action().is_none());
Source

pub fn twoway_synonyms_action(&self) -> Option<&Box<TwowaySynonymsAction>>

The value of action if it holds a TwowaySynonymsAction, None if the field is not set or holds a different branch.

Source

pub fn set_twoway_synonyms_action<T: Into<Box<TwowaySynonymsAction>>>( self, v: T, ) -> Self

Sets the value of action to hold a TwowaySynonymsAction.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::TwowaySynonymsAction;
let x = Rule::new().set_twoway_synonyms_action(TwowaySynonymsAction::default()/* use setters */);
assert!(x.twoway_synonyms_action().is_some());
assert!(x.boost_action().is_none());
assert!(x.redirect_action().is_none());
assert!(x.oneway_synonyms_action().is_none());
assert!(x.do_not_associate_action().is_none());
assert!(x.replacement_action().is_none());
assert!(x.ignore_action().is_none());
assert!(x.filter_action().is_none());
assert!(x.force_return_facet_action().is_none());
assert!(x.remove_facet_action().is_none());
assert!(x.pin_action().is_none());
Source

pub fn force_return_facet_action(&self) -> Option<&Box<ForceReturnFacetAction>>

The value of action if it holds a ForceReturnFacetAction, None if the field is not set or holds a different branch.

Source

pub fn set_force_return_facet_action<T: Into<Box<ForceReturnFacetAction>>>( self, v: T, ) -> Self

Sets the value of action to hold a ForceReturnFacetAction.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::ForceReturnFacetAction;
let x = Rule::new().set_force_return_facet_action(ForceReturnFacetAction::default()/* use setters */);
assert!(x.force_return_facet_action().is_some());
assert!(x.boost_action().is_none());
assert!(x.redirect_action().is_none());
assert!(x.oneway_synonyms_action().is_none());
assert!(x.do_not_associate_action().is_none());
assert!(x.replacement_action().is_none());
assert!(x.ignore_action().is_none());
assert!(x.filter_action().is_none());
assert!(x.twoway_synonyms_action().is_none());
assert!(x.remove_facet_action().is_none());
assert!(x.pin_action().is_none());
Source

pub fn remove_facet_action(&self) -> Option<&Box<RemoveFacetAction>>

The value of action if it holds a RemoveFacetAction, None if the field is not set or holds a different branch.

Source

pub fn set_remove_facet_action<T: Into<Box<RemoveFacetAction>>>( self, v: T, ) -> Self

Sets the value of action to hold a RemoveFacetAction.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::RemoveFacetAction;
let x = Rule::new().set_remove_facet_action(RemoveFacetAction::default()/* use setters */);
assert!(x.remove_facet_action().is_some());
assert!(x.boost_action().is_none());
assert!(x.redirect_action().is_none());
assert!(x.oneway_synonyms_action().is_none());
assert!(x.do_not_associate_action().is_none());
assert!(x.replacement_action().is_none());
assert!(x.ignore_action().is_none());
assert!(x.filter_action().is_none());
assert!(x.twoway_synonyms_action().is_none());
assert!(x.force_return_facet_action().is_none());
assert!(x.pin_action().is_none());
Source

pub fn pin_action(&self) -> Option<&Box<PinAction>>

The value of action if it holds a PinAction, None if the field is not set or holds a different branch.

Source

pub fn set_pin_action<T: Into<Box<PinAction>>>(self, v: T) -> Self

Sets the value of action to hold a PinAction.

Note that all the setters affecting action are mutually exclusive.

§Example
use google_cloud_retail_v2::model::rule::PinAction;
let x = Rule::new().set_pin_action(PinAction::default()/* use setters */);
assert!(x.pin_action().is_some());
assert!(x.boost_action().is_none());
assert!(x.redirect_action().is_none());
assert!(x.oneway_synonyms_action().is_none());
assert!(x.do_not_associate_action().is_none());
assert!(x.replacement_action().is_none());
assert!(x.ignore_action().is_none());
assert!(x.filter_action().is_none());
assert!(x.twoway_synonyms_action().is_none());
assert!(x.force_return_facet_action().is_none());
assert!(x.remove_facet_action().is_none());

Trait Implementations§

Source§

impl Clone for Rule

Source§

fn clone(&self) -> Rule

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 Rule

Source§

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

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

impl Default for Rule

Source§

fn default() -> Rule

Returns the “default value” for a type. Read more
Source§

impl Message for Rule

Source§

fn typename() -> &'static str

The typename of this message.
Source§

impl PartialEq for Rule

Source§

fn eq(&self, other: &Rule) -> 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 StructuralPartialEq for Rule

Auto Trait Implementations§

§

impl Freeze for Rule

§

impl RefUnwindSafe for Rule

§

impl Send for Rule

§

impl Sync for Rule

§

impl Unpin for Rule

§

impl UnwindSafe for Rule

Blanket Implementations§

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