encode_message

Function encode_message 

Source
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 descriptor
  • value - The VRL value to encode
  • options - 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 value is not a Value::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::Object is supported, since protobuf messages are collections of named fields
  • Fields present in the object with null values are explicitly cleared
  • Fields not present in the object retain their default protobuf values
  • Type conversion follows the mappings defined in convert_value_raw.