pub fn encode_message(
message_descriptor: &MessageDescriptor,
value: Value,
options: &Options,
) -> Result<DynamicMessage, String>Expand description
Converts a VRL Value into a protobuf DynamicMessage.
§Arguments
message_descriptor- The protobuf message schema descriptorvalue- The VRL value to encodeoptions- Encoding options (e.g., whether to use JSON field names)
§Returns
Returns Ok(DynamicMessage) on success, or Err(String) with a descriptive error message.
§Errors
- Returns an error if
valueis not aValue::Object - Returns an error if field type conversion fails (e.g., trying to encode a string as an integer)
- Returns an error if setting a field on the message fails
§Behavior
- Only
Value::Objectis supported, since protobuf messages are collections of named fields - Fields present in the object with
nullvalues are explicitly cleared - Fields not present in the object retain their default protobuf values
- Type conversion follows the mappings defined in
convert_value_raw.