Struct msi::Expr

source ·
pub struct Expr { /* private fields */ }
Expand description

An expression on database rows that can be used in queries.

Implementations§

source§

impl Expr

source

pub fn col<S: Into<String>>(column_name: S) -> Expr

Returns an expression that evaluates to the value of the specified column.

source

pub fn null() -> Expr

Returns an expression that evaluates to a null value.

source

pub fn boolean(boolean: bool) -> Expr

Returns an expression that evaluates to the given boolean value.

source

pub fn integer(integer: i32) -> Expr

Returns an expression that evaluates to the given integer value.

source

pub fn string<S: Into<String>>(string: S) -> Expr

Returns an expression that evaluates to the given string value.

source

pub fn eq(self, rhs: Expr) -> Expr

Returns an expression that evaluates to true if the two subexpressions evaluate to equal values.

source

pub fn ne(self, rhs: Expr) -> Expr

Returns an expression that evaluates to true if the two subexpressions evaluate to unequal values.

source

pub fn lt(self, rhs: Expr) -> Expr

Returns an expression that evaluates to true if the left-hand subexpression evaluates to a strictly lesser value than the right-hand subexpression.

source

pub fn le(self, rhs: Expr) -> Expr

Returns an expression that evaluates to true if the left-hand subexpression evaluates to a lesser-or-equal value than the right-hand subexpression.

source

pub fn gt(self, rhs: Expr) -> Expr

Returns an expression that evaluates to true if the left-hand subexpression evaluates to a strictly greater value than the right-hand subexpression.

source

pub fn ge(self, rhs: Expr) -> Expr

Returns an expression that evaluates to true if the left-hand subexpression evaluates to a greater-or-equal value than the right-hand subexpression.

source

pub fn bitinv(self) -> Expr

Returns an expression that computes the bitwise inverse of the subexpression. If the subexpression evaluates to a non-number, the result will be a null value.

This method exists instead of the std::ops::Not trait to distinguish it from the (logical) not() method.

source

pub fn and(self, rhs: Expr) -> Expr

Returns an expression that evaluates to true if both subexpressions evaluate to true.

source

pub fn or(self, rhs: Expr) -> Expr

Returns an expression that evaluates to true if either subexpression evaluates to true.

source

pub fn not(self) -> Expr

Returns an expression that evaluates to true if the subexpression evaluates to false.

This method exists instead of the std::ops::Not trait to distinguish it from the (bitwise) bitinv() method.

source

pub fn eval(&self, row: &Row) -> Value

Evaluates the expression against the given row. Any errors in the expression (such as dividing a number by zero, or applying a bitwise operator to a string) will result in a null value.

source

pub fn column_names(&self) -> HashSet<&str>

Returns the set of all column names referenced by this expression.

Trait Implementations§

source§

impl Add for Expr

Produces an expression that evaluates to the sum of the two subexpressions (if they are integers) or concatenation (if they are strings). If the two subexpressions evaluate to different types, or if either evaluates to a null value, the result will be a null value.

§

type Output = Expr

The resulting type after applying the + operator.
source§

fn add(self, rhs: Expr) -> Self::Output

Performs the + operation. Read more
source§

impl BitAnd for Expr

Produces an expression that evaluates to the bitwise-and of the two subexpressions. If either subexpression evaluates to a non-number, the result will be a null value.

§

type Output = Expr

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Expr) -> Self::Output

Performs the & operation. Read more
source§

impl BitOr for Expr

Produces an expression that evaluates to the bitwise-or of the two subexpressions. If either subexpression evaluates to a non-number, the result will be a null value.

§

type Output = Expr

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Expr) -> Self::Output

Performs the | operation. Read more
source§

impl BitXor for Expr

Produces an expression that evaluates to the bitwise-xor of the two subexpressions. If either subexpression evaluates to a non-number, the result will be a null value.

§

type Output = Expr

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Expr) -> Self::Output

Performs the ^ operation. Read more
source§

impl Display for Expr

source§

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

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

impl Div for Expr

Produces an expression that evaluates to the integer quotient of the two subexpressions. If either subexpression evaluates to a non-number, or if the divisor evalulates to zero, the result will be a null value.

§

type Output = Expr

The resulting type after applying the / operator.
source§

fn div(self, rhs: Expr) -> Self::Output

Performs the / operation. Read more
source§

impl Mul for Expr

Produces an expression that evaluates to the product of the two subexpressions. If either subexpression evaluates to a non-number, the result will be a null value.

§

type Output = Expr

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Expr) -> Self::Output

Performs the * operation. Read more
source§

impl Neg for Expr

Produces an expression that evaluates to the negative of the subexpression. If the subexpression evaluates to a non-number, the result will be a null value.

§

type Output = Expr

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl Shl for Expr

Produces an expression that evaluates to the value of the left-hand subexpression bit-shifted left by the value of the right-hand subexpression. If either subexpression evaluates to a non-number, the result will be a null value.

§

type Output = Expr

The resulting type after applying the << operator.
source§

fn shl(self, rhs: Expr) -> Self::Output

Performs the << operation. Read more
source§

impl Shr for Expr

Produces an expression that evaluates to the value of the left-hand subexpression bit-shifted right by the value of the right-hand subexpression. If either subexpression evaluates to a non-number, the result will be a null value.

§

type Output = Expr

The resulting type after applying the >> operator.
source§

fn shr(self, rhs: Expr) -> Self::Output

Performs the >> operation. Read more
source§

impl Sub for Expr

Produces an expression that evaluates to the difference of the two subexpressions. If either subexpression evaluates to a non-number, the result will be a null value.

§

type Output = Expr

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Expr) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnwindSafe for Expr

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToString for Twhere 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 Twhere 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 Twhere 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.