fn generate_setter_body(
struct_name: &Ident,
slot: &SidecarSlot,
_prot_index_lit: &LitInt,
) -> TokenStreamExpand description
Generate the token stream for a sidecar setter function body.
Converts the incoming R SEXP value and writes it to the corresponding
Rust struct field. The conversion strategy depends on the slot kind:
RawSexp: stores the SEXP directly.- Scalar kinds: uses
Rf_as*or coercion for single-element extraction; an input that doesn’t reduce to a single non-NA scalar raises a conversion error instead of silently storing an NA/falsesentinel. Conversion: usesTryFromSexp::try_from_sexp; a failed conversion raises a conversion error instead of silently dropping the write.
Returns the external pointer x (for R’s invisible return convention).
The body runs inside with_r_unwind_protect (see the emission site in
generate_sidecar_accessors); a bad receiver panics with the main-path
expected ExternalPtr<T> message and conversion failures return a tagged
condition SEXP with kind conversion — both are re-raised by the R
wrapper. Sidecar accessors have no __miniextendr_call slot (#344/#348),
so the tagged conditions carry null call attribution.