Skip to main content

Modifiers

Struct Modifiers 

Source
pub(crate) struct Modifiers {
Show 16 fields is_monotone: Option<Expr>, is_infinity_monotone: Option<Expr>, sqlname: Option<SqlName>, preserves_uniqueness: Option<Expr>, inverse: Option<Expr>, negate: Option<Expr>, is_infix_op: Option<Expr>, output_type: Option<Path>, output_type_expr: Option<Expr>, could_error: Option<Expr>, propagates_nulls: Option<Expr>, introduces_nulls: Option<Expr>, is_associative: Option<Expr>, is_eliminable_cast: Option<Expr>, test: Option<bool>, skip_display: Option<bool>,
}
Expand description

Modifiers passed as key-value pairs to the #[sqlfunc] macro.

Fields§

§is_monotone: Option<Expr>

Whether the function is monotone with respect to its arguments. Binary functions take a pair of expressions, one per argument.

§is_infinity_monotone: Option<Expr>

Whether is_monotone’s endpoint-sampling guarantee still holds when an operand may be infinite. Set false for multiplication and division.

§sqlname: Option<SqlName>

The SQL name for the function.

§preserves_uniqueness: Option<Expr>

Whether the function preserves uniqueness.

§inverse: Option<Expr>

The inverse of the function, if it exists.

§negate: Option<Expr>

The negated function, if it exists.

§is_infix_op: Option<Expr>

Whether the function is an infix operator.

§output_type: Option<Path>

The output type of the function, if it cannot be inferred.

§output_type_expr: Option<Expr>

The output type of the function as an expression.

§could_error: Option<Expr>

Whether the function could error.

§propagates_nulls: Option<Expr>

Whether the function propagates nulls.

§introduces_nulls: Option<Expr>

Whether the function introduces nulls.

§is_associative: Option<Expr>

Whether the function is associative.

§is_eliminable_cast: Option<Expr>

Whether the function is a noop cast.

§test: Option<bool>

Whether to generate a snapshot test for the function. Defaults to false.

§skip_display: Option<bool>

Suppresses the generated fmt::Display. Set this when the struct’s name depends on its state, so the call site keeps a hand-written impl.

Implementations§

Source§

impl Modifiers

Source

pub(crate) fn generates_test(&self) -> bool

Whether the call site asked for a generated snapshot test.

Source

pub(crate) fn sqlname(&self) -> Option<&SqlName>

The SQL name the generated Display writes, if the call site overrides the function’s name.

Source

pub(crate) fn output_type(&self) -> Option<&Path>

The type whose column type is the function’s output type, if the call site overrides the one derived from the return type.

Source

pub(crate) fn output_type_expr(&self) -> Option<&Expr>

An expression computing the function’s output column type, if the call site overrides the one derived from the return type.

Source

pub(crate) fn skip_display(&self) -> bool

Whether the call site asked to suppress the generated Display impl.

Source

pub(crate) fn get(&self, modifier: Modifier) -> Option<&Expr>

The expression the call site gave a method-producing modifier, if any.

Source

pub(crate) fn validate(&self, shape: Shape, has_self: bool) -> Result<()>

Errors if a modifier does not apply to shape, or conflicts with another modifier or with the function’s receiver. Reports every problem, each at the modifier it concerns.

Trait Implementations§

Source§

impl Debug for Modifiers

Source§

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

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

impl Default for Modifiers

Source§

fn default() -> Modifiers

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

impl FromMeta for Modifiers

Source§

fn from_list(__items: &[NestedMeta]) -> Result<Self>

Create an instance from a list of nested meta items.
Source§

fn from_nested_meta(item: &NestedMeta) -> Result<Self, Error>

Source§

fn from_meta(item: &Meta) -> Result<Self, Error>

Create an instance from a syn::Meta by dispatching to the format-appropriate trait function. This generally should not be overridden by implementers. Read more
Source§

fn from_none() -> Option<Self>

When a field is omitted from a parent meta-item, from_none is used to attempt recovery before a missing field error is generated. Read more
Source§

fn from_word() -> Result<Self, Error>

Create an instance from the presence of the word in the attribute with no additional options specified.
Source§

fn from_value(value: &Lit) -> Result<Self, Error>

Create an instance from a literal value of either foo = "bar" or foo("bar"). This dispatches to the appropriate method based on the type of literal encountered, and generally should not be overridden by implementers. Read more
Source§

fn from_expr(expr: &Expr) -> Result<Self, Error>

Source§

fn from_invalid_expr(value: &MetaNameValueInvalidExpr) -> Result<Self, Error>

name = value where the value failed to parse as a syn::Expr. Read more
Source§

fn from_char(value: char) -> Result<Self, Error>

Create an instance from a char literal in a value position.
Source§

fn from_string(value: &str) -> Result<Self, Error>

Create an instance from a string literal in a value position.
Source§

fn from_bool(value: bool) -> Result<Self, Error>

Create an instance from a bool literal in a value position.

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.