Expand description
Analysis of a #[sqlfunc]-annotated functionβs signature.
These helpers read syn types and answer what a generated trait impl needs to
know about the function it wraps: its associated types once generic parameters
are erased, which input positions reject NULL, and the output type a polymorphic
signature implies. Nothing here reads the attributeβs modifiers or the arity
tables, so it stays a leaf of the crate.
EnumsΒ§
- Generic
Usage π - How a generic type parameter
Tappears in a type.
FunctionsΒ§
- camel_
case π - Convert an identifier to a camel-cased identifier.
- classify_
generic_ πusage - Classifies how a generic type parameter appears in a type.
- container_
idents_ πmatch - Compare two container type paths by their ident segments (ignoring lifetimes and generic arguments). Two containers are βsameβ if their path idents match.
- derive_
output_ πtype_ for_ generic - Derives an
output_type_exprfor a single generic parameter, which appears in the output type asoutput_usage. - derive_
output_ πtype_ for_ generics - Derives an
output_type_exprTokenStream from the structural relationship between input types and the output type, based on where generic parameters appear. - element_
type_ πexpr - Generates a token stream that extracts the T-level SQL type from an input access expression, based on how T is used in that input.
- elide_
lifetimes π - Replaces all lifetime parameters in a
syn::TypePathwith'_. - elide_
lifetimes_ πin_ type - Recursively replaces all lifetime parameters in a
syn::Typewith'_. - erase_
all_ πgeneric_ params - Erases all generic type parameters from a type, replacing each with
Datum<'a>. - erase_
generic_ πparam - Replaces occurrences of a generic type parameter with
Datum<'a>in a type. - find_
generic_ πtype_ params - Extracts generic type parameters from a function signature. Returns an empty Vec if there are no type parameters.
- has_
receiver π - Checks if the function takes a
selfreceiver. - is_
nullable_ πtype - Checks if a parameter type accepts NULL.
- is_
option_ πwrapped - Returns whether the outermost wrapper of a type is
Option. - is_
variadic_ πarg - Checks whether a parameterβs type is
Variadic<...>orOptionalArg<...>, which makes the function variadic regardless of parameter count. - is_
variadic_ πtype - Checks if a type is
Variadic<T>. - last_
is_ πarena - Checks if the last parameter of the function is a
&RowArena. - non_
nullable_ πposition_ checks - Generates per-position nullability checks for non-nullable parameters.
- output_
type π - Determine the output type for a function. Returns an error if the function does not return a value.
- patch_
lifetimes π - Recursively patches lifetimes in a type, adding
'ato references without a lifetime and recursing into generic arguments and tuples. - sql_
args π - The parameters that carry SQL arguments, which excludes a
&selfreceiver and a trailing&RowArena. - type_
contains_ πident - Returns whether a type syntactically contains an identifier.
- variadic_
element_ πis_ nullable - For a
Variadic<T>type, checks ifTaccepts NULL.