#[non_exhaustive]pub enum Condition {
Show 13 variants
Read {
field: FieldRead,
},
Bool {
value: bool,
},
Int {
value: i64,
},
Float {
value: f64,
},
Var {
name: String,
},
Compare {
op: CompareOp,
left: Box<Condition>,
right: Box<Condition>,
},
And {
operands: Vec<Condition>,
},
Or {
operands: Vec<Condition>,
},
Not {
operand: Box<Condition>,
},
Arith {
op: ArithOp,
left: Box<Condition>,
right: Box<Condition>,
},
UnaryMath {
op: UnaryMathOp,
operand: Box<Condition>,
},
MinMax {
op: MinMaxOp,
left: Box<Condition>,
right: Box<Condition>,
},
IfThenElse {
condition: Box<Condition>,
then: Box<Condition>,
otherwise: Box<Condition>,
},
}Expand description
Composable condition tree used by authored rotations.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Implementations§
Source§impl Condition
impl Condition
Sourcepub fn children(&self) -> impl Iterator<Item = &Condition>
pub fn children(&self) -> impl Iterator<Item = &Condition>
Iterator over this node’s direct child conditions.
Sourcepub fn walk<'a>(&'a self, visitor: &mut impl FnMut(&'a Condition))
pub fn walk<'a>(&'a self, visitor: &mut impl FnMut(&'a Condition))
Visits every node in the tree (pre-order), iteratively to avoid stack overflow on WASM.
Sourcepub fn walk_with_depth<'a>(
&'a self,
visitor: &mut impl FnMut(&'a Condition, usize),
)
pub fn walk_with_depth<'a>( &'a self, visitor: &mut impl FnMut(&'a Condition, usize), )
Visits every node and its one-based depth in pre-order.
Sourcepub fn field_reads(&self) -> Vec<&FieldRead>
pub fn field_reads(&self) -> Vec<&FieldRead>
Collects every FieldRead leaf in the tree.
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl FromWasmAbi for Conditionwhere
Self: DeserializeOwned,
impl FromWasmAbi for Conditionwhere
Self: DeserializeOwned,
Source§impl IntoWasmAbi for &Condition
impl IntoWasmAbi for &Condition
Source§impl IntoWasmAbi for Condition
impl IntoWasmAbi for Condition
Source§impl JsonSchema for Condition
impl JsonSchema for Condition
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl OptionFromWasmAbi for Conditionwhere
Self: DeserializeOwned,
impl OptionFromWasmAbi for Conditionwhere
Self: DeserializeOwned,
Source§impl OptionIntoWasmAbi for Condition
impl OptionIntoWasmAbi for Condition
Source§impl RefFromWasmAbi for Conditionwhere
Self: DeserializeOwned,
impl RefFromWasmAbi for Conditionwhere
Self: DeserializeOwned,
Source§type Abi = <JsType as RefFromWasmAbi>::Abi
type Abi = <JsType as RefFromWasmAbi>::Abi
The Wasm ABI type references to
Self are recovered from.Source§impl Tsify for Condition
impl Tsify for Condition
const DECL: &'static str = "/**\n * Composable condition tree used by authored rotations.\n */\nexport type Condition = ({ type: \"read\" } & {} & FieldRead) | { type: \"bool\"; value: boolean } | { type: \"int\"; value: number } | { type: \"float\"; value: number } | { type: \"var\"; name: string } | { type: \"compare\"; op: CompareOp; left: Condition; right: Condition } | { type: \"and\"; operands: Condition[] } | { type: \"or\"; operands: Condition[] } | { type: \"not\"; operand: Condition } | { type: \"arith\"; op: ArithOp; left: Condition; right: Condition } | { type: \"unary_math\"; op: UnaryMathOp; operand: Condition } | { type: \"min_max\"; op: MinMaxOp; left: Condition; right: Condition } | { type: \"if_then_else\"; condition: Condition; then: Condition; otherwise: Condition };"
const SERIALIZATION_CONFIG: SerializationConfig
type JsType = JsType
fn into_js(&self) -> Result<Self::JsType, Error>where
Self: Serialize,
fn from_js<T>(js: T) -> Result<Self, Error>
Source§impl VectorFromWasmAbi for Conditionwhere
Self: DeserializeOwned,
impl VectorFromWasmAbi for Conditionwhere
Self: DeserializeOwned,
type Abi = <JsType as VectorFromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[Self]>
Source§impl VectorIntoWasmAbi for Condition
impl VectorIntoWasmAbi for Condition
type Abi = <JsType as VectorIntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[Self]>) -> Self::Abi
Source§impl WasmDescribeVector for Condition
impl WasmDescribeVector 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 UnsafeUnpin for Condition
impl UnwindSafe for Condition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.