Enum dmntk_feel::values::Value

source ·
pub enum Value {
Show 40 variants Boolean(bool), BuiltInFunction(Bif), Context(FeelContext), ContextEntry(Name, Box<Value>), ContextEntryKey(Name), ContextType(FeelType), ContextTypeEntry(Name, FeelType), ContextTypeEntryKey(Name), Date(FeelDate), DateTime(FeelDateTime), DaysAndTimeDuration(FeelDaysAndTimeDuration), ExpressionList(Values), ExternalJavaFunction(String, String), ExternalPmmlFunction(String, String), FeelType(FeelType), FormalParameter(Name, FeelType), FormalParameters(Vec<(Name, FeelType)>), FunctionBody(FunctionBody, bool), FunctionDefinition(Vec<(Name, FeelType)>, FunctionBody, bool, Closure, FeelContext, FeelType), IntervalEnd(Box<Value>, bool), IntervalStart(Box<Value>, bool), Irrelevant, List(Values), NamedParameter(Box<Value>, Box<Value>), NamedParameters(BTreeMap<Name, (Value, usize)>), NegatedCommaList(Values), Null(Option<String>), Number(FeelNumber), ParameterName(Name), ParameterTypes(Vec<Value>), PositionalParameters(Values), QualifiedNameSegment(Name), Range(Box<Value>, bool, Box<Value>, bool), String(String), Time(FeelTime), UnaryGreater(Box<Value>), UnaryGreaterOrEqual(Box<Value>), UnaryLess(Box<Value>), UnaryLessOrEqual(Box<Value>), YearsAndMonthsDuration(FeelYearsAndMonthsDuration),
}
Expand description

FEEL value.

Variants§

§

Boolean(bool)

Value representing FEEL boolean type.

§

BuiltInFunction(Bif)

Value for storing built-in function definition.

§

Context(FeelContext)

Value representing a context.

§

ContextEntry(Name, Box<Value>)

Value representing a context entry.

§

ContextEntryKey(Name)

Value representing a key of the context entry.

§

ContextType(FeelType)

Value representing the context type.

§

ContextTypeEntry(Name, FeelType)

Value representing a context entry in context type definition.

§

ContextTypeEntryKey(Name)

Value representing a key of the context entry in context type definition.

§

Date(FeelDate)

Value for storing dates as FeelDate.

§

DateTime(FeelDateTime)

Value for storing date and time as FeelDateTime.

§

DaysAndTimeDuration(FeelDaysAndTimeDuration)

Value for days and time durations.

§

ExpressionList(Values)

Value representing a collection of comma-separated list of expressions.

§

ExternalJavaFunction(String, String)

Value representing a mapping to externally defined Java function.

Tuple Fields

§0: String

Class name.

§1: String

Method signature.

§

ExternalPmmlFunction(String, String)

Value representing a mapping to externally defined PMML function.

Tuple Fields

§0: String

Document.

§1: String

Model name.

§

FeelType(FeelType)

Value representing the FEEL type of a value.

§

FormalParameter(Name, FeelType)

Value representing function’s formal parameter with name and type.

§

FormalParameters(Vec<(Name, FeelType)>)

List of formal parameters.

§

FunctionBody(FunctionBody, bool)

Definition of the function body.

Tuple Fields

§0: FunctionBody

Body of the function.

§1: bool

Flag indicating if the function’s body is an external function, true == external.

§

FunctionDefinition(Vec<(Name, FeelType)>, FunctionBody, bool, Closure, FeelContext, FeelType)

Value representing the function definition. This value holds the list of function’s formal parameters, the function’s body, closure for lambdas and expected result type.

Tuple Fields

§0: Vec<(Name, FeelType)>

Formal parameters of the function.

§1: FunctionBody

Body of the function.

§2: bool

Flag indicating if the function’s body is an external function, true == external.

§3: Closure

Closed names from function context (closure names).

§4: FeelContext

Values of the closed names (closure values).

§5: FeelType

Return type of the function.

§

IntervalEnd(Box<Value>, bool)

Value representing interval end.

§

IntervalStart(Box<Value>, bool)

Value representing interval start.

§

Irrelevant

Value representing FEEL irrelevant value.

§

List(Values)

Value representing a list of values.

§

NamedParameter(Box<Value>, Box<Value>)

Named parameter.

§

NamedParameters(BTreeMap<Name, (Value, usize)>)

Value representing a collection of named parameters.

§

NegatedCommaList(Values)

Value representing a collection of values representing a negated comma-separated list of expressions.

§

Null(Option<String>)

Null value with optional tracing message.

§

Number(FeelNumber)

Value representing FEEL number type.

§

ParameterName(Name)

Name of the parameter.

§

ParameterTypes(Vec<Value>)

Value representing a list of function’s parameter types.

§

PositionalParameters(Values)

List of positional parameters.

§

QualifiedNameSegment(Name)

Value representing a segment of a qualified name.

§

Range(Box<Value>, bool, Box<Value>, bool)

Value representing a range.

§

String(String)

String value…

§

Time(FeelTime)

Value for storing time as FeelTime.

§

UnaryGreater(Box<Value>)

UnaryGreater value…

§

UnaryGreaterOrEqual(Box<Value>)

UnaryGreaterOrEqual value…

§

UnaryLess(Box<Value>)

UnaryLess value…

§

UnaryLessOrEqual(Box<Value>)

UnaryLessOrEqual value…

§

YearsAndMonthsDuration(FeelYearsAndMonthsDuration)

Value for storing years and months duration.

Implementations§

source§

impl Value

source

pub fn is_null(&self) -> bool

Returns true when the value is of type Value::Null.

source

pub fn is_true(&self) -> bool

Returns true when the value is of type Value::Boolean and is equal to true.

source

pub fn is_number(&self) -> bool

Returns true when the value is of type Value::Number.

source

pub fn is_invalid_coercion(&self) -> bool

Returns true when the value is of type Value::Null indicating invalid coercion.

source

pub fn type_of(&self) -> FeelType

Returns the type of this Value.

source

pub fn is_conformant(&self, target_type: &FeelType) -> bool

Checks if a value is conformant with specified target type.

source

pub fn coerced(&self, target_type: &FeelType) -> Value

Returns value coerced to specified type. When a value appears in a certain context, it must be compatible with a type expected in that context, called the target type. After the type of the value is known, an implicit conversion from the type of the value to the target type can be performed. If an implicit conversion is mandatory but it cannot be performed, the result is null.

There are several possible type conversions:

  • to singleton list:

    When the type of the value is T and the target type is List<T>, the simple value is converted to a singleton list.

  • from singleton list:

    When the type of the value is List<T>, and the value is a singleton list and the target type is T, the value is converted by unwrapping the first element.

  • conforms to:

    When the type of the value is T1, the target type is T2, and T1 conforms to T2, the value remains unchanged. Otherwise the result is null.

All these conversion rules are implemented in this function.

source

pub fn try_from_xsd_integer(text: &str) -> Result<Self>

Tries to convert xsd:integer string into valid Value representing a number.

source

pub fn try_from_xsd_decimal(text: &str) -> Result<Self>

Tries to convert xsd:decimal string into valid Value representing a number.

source

pub fn try_from_xsd_double(text: &str) -> Result<Self>

Tries to convert xsd:double string into valid Value representing a number.

source

pub fn try_from_xsd_boolean(text: &str) -> Result<Self>

Tries to convert xsd:boolean string into valid Value representing a boolean.

source

pub fn try_from_xsd_date(text: &str) -> Result<Self>

Tries to convert xsd:date string into valid Value representing a date. FEEL date format is fully conformant with xsd:date.

source

pub fn try_from_xsd_time(text: &str) -> Result<Self>

Tries to convert xsd:time string into valid Value representing a time. FEEL time format is fully conformant with xsd:time.

source

pub fn try_from_xsd_date_time(text: &str) -> Result<Self>

Tries to convert xsd:dateTime string into valid Value representing a date and time. FEEL date and time format is fully conformant with xsd:dateTime.

source

pub fn try_from_xsd_duration(text: &str) -> Result<Self>

Tries to convert xsd:duration string into valid Value representing a date and time. FEEL durations are conformant with xsd:duration but spit into two ranges.

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

Returns a copy 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 Value

source§

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

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

impl Display for Value

source§

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

Converts Value into string.

source§

impl From<FeelContext> for Value

source§

fn from(ctx: FeelContext) -> Self

Converts FeelContext to Value.

source§

impl Jsonify for Value

source§

fn jsonify(&self) -> String

Converts a Value into JSON.

source§

impl PartialEq for Value

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToFeelString for Value

source§

fn to_feel_string(&self) -> String

Converts Value into FEEL string.

source§

impl TryFrom<&ComponentDto> for Value

source§

fn try_from(value: &ComponentDto) -> Result<Self, Self::Error>

Converts a ComponentDto to Value.

§

type Error = DmntkError

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

impl TryFrom<&ListDto> for Value

source§

fn try_from(value: &ListDto) -> Result<Self, Self::Error>

Converts a ListDto to Value.

§

type Error = DmntkError

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

impl TryFrom<&SimpleDto> for Value

source§

fn try_from(value: &SimpleDto) -> Result<Self, Self::Error>

Converts SimpleDto into Value.

§

type Error = DmntkError

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

impl TryFrom<&Value> for ValueDto

source§

fn try_from(value: &Value) -> Result<Self, Self::Error>

Converts a Value to ValueDto.

§

type Error = DmntkError

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

impl TryFrom<&ValueDto> for Value

source§

fn try_from(value: &ValueDto) -> Result<Self, Self::Error>

Converts a ValueDto to Value.

§

type Error = DmntkError

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

impl TryFrom<&Vec<ComponentDto>> for Value

source§

fn try_from(object: &Vec<ComponentDto>) -> Result<Self, Self::Error>

Converts an [ObjectDto] to Value.

§

type Error = DmntkError

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

impl TryFrom<Value> for FeelContext

source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Converts Value to FeelContext.

§

type Error = DmntkError

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

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl !UnwindSafe for Value

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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

§

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.