Expand description
Code generation for #[derive(RCondition)].
Generates impl miniextendr_api::condition::RConditionData from the
type’s structure, and From<T> for miniextendr_api::condition::RCondition,
so a package keeps one Rust type per condition family and gets the R side
without hand-written glue:
-
class():c(<member>, <family>)for enum variants,c(<family>)for structs.#[condition(class("…", "…"))]on a struct is its whole class vector, and on a variant it replaces the member. The family is#[condition(class = "…")]on the type, else the type name in snake_case; the member is the same attribute on the variant, else<family>_<variant in snake_case>. -
message():#[condition(message = "…")]on the struct or on a variant is aformat!string with the fields in scope (tuple fields as_0,_1, …). Without it the message is the type’sDisplayrendering. -
data(): every field as a named entry built withRValue::from(field.clone()).#[condition(rename = "…")]changes the name,#[condition(skip)]drops the field,#[condition(debug)]attaches theDebugrendering (RValue::debug) instead of a conversion. Tuple fields needrenameorskip; the condition’s own slots (message,call,kind) are rejected.#[condition(skip_none)]on anOptionfield leaves its entry out when it isNone.#[condition(data(name = value, …))]on the type or a variant adds entries after the fields’, eachRValue::from(value). With no entries,data()isNone. -
call():#[condition(call = none)]on the type (every variant) or on one variant raises that condition without a call (conditionCall()isNULL, R’scall. = FALSE). Without it the method keeps the trait’s default, the call the transport captured. -
argument_message():#[condition(argument_message = "…")]on the struct or on a variant, aformat!string likemessage. It is the whole message when the error refuses an argument in a conversion (#1833); a variant without it keeps the trait’s default,None. -
From<T> for RCondition: the kind is#[condition(kind = …)]on the variant, else on the type, elseerror. OnlyRCondition::from(x)(.defer()/.raise()) reads it: a returnedErr(x)is always an R error, anddefer_warning(x)/defer_message(x)choose their own kind.
The payload feeds defer_warning & co. (a condition accompanying a value)
and Result<T, E> returns (a classed error): both go through the trait.
Generic types are rejected, like the other derives in this crate.
Structs§
- Container
Attrs 🔒 #[condition(...)]options on the type or on one variant.- Data
Entry 🔒 - One
data(name = value)entry. - Field
Attrs 🔒 #[condition(...)]options on one field.- Field
Info 🔒 - One field of a struct or variant, as the derive sees it.
- Shape 🔒
- The fields of a struct or of one enum variant, validated, with the
data(...)entries that follow them.
Enums§
Constants§
- RESERVED_
FIELDS 🔒 - The condition object’s own slots. Mirrors
miniextendr_api::condition::RESERVED_CONDITION_FIELDS; keep in sync.
Functions§
- check_
data_ 🔒name - Refuse a name the condition object owns, or one already in
seen. - condition_
expr 🔒 - The
RConditionvariant for a declared kind; no kind is an error. - derive_
condition 🔒 - derive_
r_ condition - Main entry point for
#[derive(RCondition)]: theRConditionDatametadata andFrom<T> for RConditionwith the declared kind. - is_
option 🔒 - Whether
tyis written asOption<_>(any path ending inOption). - parse_
container_ 🔒attrs - parse_
field_ 🔒attrs