Skip to main content

IntoContext

Derive Macro IntoContext 

Source
#[derive(IntoContext)]
Expand description

Derive IntoContext for a struct, converting its fields into Context key-value pairs.

Field type mapping:

  • String / &str / &'a str → Value::String (borrowed strs are cloned)
  • i8, i16, i32, i64, isize, u8, u16, u32 → Value::Number via infallible as i64 cast
  • u64, usize → Value::Number via saturating conversion: values above i64::MAX (≈9.2 × 10¹⁸) saturate to i64::MAX rather than wrapping to a negative. If you need the raw bit pattern, convert explicitly in host code before constructing the context.
  • Vec<String> → Value::List
  • Option<T> where T is any of the above → inserted only when Some(_)

Unsupported field types produce a compile-time error so template slots cannot silently disappear.