Skip to main content

field_assignment

Function field_assignment 

Source
pub fn field_assignment(
    unified_type: &UnifiedType,
    field_ident: &Ident,
    ctx: &RenderContext,
    runtime: Runtime,
) -> TokenStream
Expand description

Generate field assignment code.

Wraps a constructor/builder parameter so it can be stored into the request struct field. runtime selects the ABI of the protobuf library the generated code consumes:

  • Runtime::Prost: open enums are i32 (#field as i32); singular message/oneof fields are Option<Box<T>> (Some(#field)).
  • Runtime::Buffa: open enums are EnumValue<E> (buffa::EnumValue::Known(#field)); singular message/oneof fields are MessageField<T> (buffa::MessageField::some(#field)).