Skip to main content

Module type_inspect

Module type_inspect 

Source
Expand description

Lightweight type-introspection helpers shared by parsing and codegen.

StructsΒ§

ChoiceLayers πŸ”’
The wrappers around the value of a match_arg / choices parameter, peeled outermost first: Missing<..>, then Option<..>, then Either<T, R> with the choice on the left (a scalar choice, or a several_ok list: Either<Vec<T>, R>, #1612). A plain T (or a plain several_ok container) has none.
UnevaluatedParam πŸ”’
An unevaluated-argument parameter: Quoted / Quosure, or either inside Missing<..> (optional).

EnumsΒ§

ParamMarker πŸ”’
A by-value parameter marker the macro peels from a parameter type before any R-side analysis: the parameter converts as the inner type, and the C wrapper wraps the value (<ctor>::from_inner(x)) before the call.
ParamMarkerFamily πŸ”’
The decision family a ParamMarker belongs to: a parameter carries at most one marker per family.
SeveralOkContainer πŸ”’
Container family for a several_ok parameter, returned by classify_several_ok_container.
UnevaluatedKind πŸ”’
Which unevaluated-argument marker a parameter takes.

ConstantsΒ§

MAIN_THREAD_BOUND πŸ”’
Framework type names that hold R memory and are !Send by design.

FunctionsΒ§

call_marker πŸ”’
Detect a condition-call marker parameter type: Call selects wrapper attribution, CallerCall selects caller. Matched on the last path segment like the visibility markers; a segment carrying generic arguments (Call<T>) is some other type. References and wrappers (&Call, Option<Call>) are not markers: the C wrapper binds the marker by value from its hidden call slot.
choice_layer_name πŸ”’
The layer name ("Missing" / "Option" / "Either") when ty is itself a layer type, i.e. when it sits where the choice value should be. Used to reject layers in an unsupported order, such as Option<Missing<T>> or Either<Option<T>, R>.
choice_layers πŸ”’
Peel the ChoiceLayers of a choice parameter’s type.
classify_several_ok_container πŸ”’
Classify a several_ok parameter type into one of the four container families and extract its inner element type T.
either_arms πŸ”’
(L, R) for an Either<L, R> type (last path segment Either with two type arguments), None for anything else.
erase_lifetimes πŸ”’
ty with every lifetime replaced by '_, for a let binding annotation in generated code: &'a [f64] β†’ &'_ [f64]. The binding then names the target type (so the error type of its conversion is known where the wrapper inspects it) without depending on the user’s lifetime parameters being in scope.
first_type_argument πŸ”’
Returns the first generic type argument from a path segment.
is_lazy_dots_marker πŸ”’
Detect the unforced-dots parameter type, LazyDots: matched on the last path segment like the other markers, bare or with lifetime arguments only (LazyDots<'_>). Only the whole type by value is the parameter; any other shape (&LazyDots, Option<LazyDots>, Missing<LazyDots>) is refused by the callers through mentions_lazy_dots.
is_main_thread_bound_input πŸ”’
Returns true if ty is an input type bound to the R main thread.
is_main_thread_bound_return πŸ”’
Returns true if ty is (or contains) a main-thread-bound type anywhere in a return position β€” e.g. BuiltDataFrame, Result<BuiltDataFrame, String>, Option<DataFrameShape>, Vec<BuiltDataFrame>.
is_nargs_marker πŸ”’
Detect the argument-count marker parameter type, NArgs: matched on the last path segment like call_marker, with no generic arguments. References and wrappers (&NArgs, Option<NArgs>) are not the marker.
is_option_type πŸ”’
true when the last path segment of ty is Option<...>.
is_rng_guard_param πŸ”’
Detect the RNG guard parameter type, &RngGuard (a shared reference to a path whose last segment is RngGuard, with no generic arguments, any lifetime). Under #[miniextendr(rng)] the parameter is no R formal: the wrapper has loaded R’s RNG state and passes its guard at that position.
is_rooted_reference πŸ”’
Explicit shared reference forms whose main-thread conversions borrow a root: the references, their Options, and Vecs of either (nested Vecs too). Keep worker selection separate: &str uses owned storage on the worker, while mutable/custom references still need their existing conversion path.
is_rooted_view πŸ”’
Conversions selected from the rooted call argument rather than a raw SEXP. The Cow vector cases are character vectors, not arbitrary lists of views.
is_sexp_type πŸ”’
Returns true if ty is syntactically SEXP.
marker_in_family πŸ”’
Whether any of markers is in family, and which.
match_arg_choices_ty πŸ”’
Resolve the MatchArg-bound type behind a match_arg parameter.
mentions_lazy_dots πŸ”’
Whether ty names LazyDots anywhere, at any depth.
mentions_rng_guard πŸ”’
Whether ty names RngGuard anywhere: a parameter that does without being is_rng_guard_param (&mut RngGuard, RngGuard by value, Option<&RngGuard>) is a shape the wrapper cannot fill.
mentions_unevaluated_marker πŸ”’
Whether ty names Quoted / Quosure anywhere, at any depth.
nested_param_marker πŸ”’
A marker inside Option<..> / Missing<..> / Vec<..> / &.., at any depth of those wrappers.
nth_type_argument πŸ”’
Returns the n-th generic type argument from a path segment.
option_inner_type πŸ”’
Return T for an Option<T> type, None for anything else.
outer_param_marker πŸ”’
The marker a type’s outermost segment names, with its single type argument. Matched on the last path segment like peel_visibility_marker; a bare Checked (no type argument) or one with two is not a marker (the fail-safe direction: the type then fails to convert).
peel_external_ptr πŸ”’
Return T for an ExternalPtr<T> class handle, ty itself otherwise.
peel_param_markers πŸ”’
Peel the parameter markers off a parameter type, outermost first: returns the markers in the order written and the inner type the parameter converts as. Checked<Strict<T>>-style stacks of different families peel in one pass; two markers of one family (Checked<Unchecked<T>>) are an error, as is a marker nested inside Option / Missing / Vec / & (at any depth of those), where the conversion has no marker to unwrap.
peel_return_visibility πŸ”’
peel_visibility_marker over a whole syn::ReturnType: returns the marker’s decision and an owned return type with the marker removed, so the rest of the analysis (Option/Result shapes, Self, thread strategy) sees exactly what it would without the marker.
peel_visibility_marker πŸ”’
Peel a return-visibility marker (Invisible<T> / Visible<T>, matched on the last path segment like Dots / Missing).
prepare_return_value πŸ”’
Prepare the value to match the type used by return analysis. Both functions and method/shim paths unwrap visibility before applying serde transport.
r_value_noun πŸ”’
How R documentation names a value of type ty, with its article: "a data frame", "a list", "a number", "a character vector", … Used for the R arm of an Either<T, R> choice parameter in its auto-generated @param line (One of "a", "b", or a data frame.). A type without an R name falls back to its Rust spelling in code format.
resolve_visibility πŸ”’
Resolve the wrapper’s visibility from the three sources, most explicit first: a return-type marker, then the invisible / visible attribute, then the shape default. A marker and an attribute that disagree are an error at span.
rng_guard_arg πŸ”’
The argument expression for an &RngGuard parameter: a borrow of a guard made at the call, which the wrapper has loaded the state for and saves itself (the guard saves nothing when it drops). No binding, so no user parameter name can capture it.
second_type_argument πŸ”’
Returns the second generic type argument from a path segment.
self_ref_mutability πŸ”’
Whether a bare &Self / &mut Self parameter is mutable. None means this is not a Self-reference parameter.
serialize_return_type πŸ”’
Model #[miniextendr(serialize)] exactly like a declared AsSerialize<T> return, after peeling an outer visibility marker. In particular, Option and Result inside it are serde data, not boundary control flow.
signature_holds_r_values πŸ”’
Returns true if a method signature passes an R value across the call: a main-thread-bound input (an unevaluated Quoted / Quosure under Missing<..> too) or a main-thread-bound return. Such a static method stays on the main thread even when worker or worker-default selects the worker, the rule standalone functions follow.
static_lifetime πŸ”’
The first 'static lifetime written anywhere in ty.
static_rooted_view_binding πŸ”’
A 'static borrowed parameter (StrVec<'static>, Cow<'static, str>, &'static [T], Option<&'static str>) can never be bound: its root is the call’s argument slot, or on the worker a copy that ends with the call. Returns the statement that binds ident with a compile_error! naming the fix, spanned at the lifetime, in place of a borrow-checker error about a generated temporary. The binding keeps the code that uses ident free of follow-on errors; it does not diverge, so that code draws no unreachable warning.
type_display πŸ”’
Render a type the way it is written in Rust source, for user-facing messages: AsFromStrVec<i32>, Either<i32, String>, &[f64], &'a str, Option<Vec<String>>.
unevaluated_param πŸ”’
Detect an unevaluated-argument parameter type, matched on the last path segment like the other markers: Quoted, Quosure, or one of them as the type argument of Missing<..>. Any other position (Option<Quoted>, &Quoted) is not one; mentions_unevaluated_marker lets the caller refuse it.
vector_noun πŸ”’
The R name of a vector with elements of type elem, if it has one.
visibility_marker_error πŸ”’
The error for a marker that cannot be honoured: a nested marker (Invisible<Visible<T>>), a marker in argument position, or, the mirror case, a parameter marker (Checked<T> / Unchecked<T>) in return position (also inside a visibility marker).
write_type_tokens πŸ”’