Skip to main content

ProstValue

Derive Macro ProstValue 

Source
#[derive(ProstValue)]
{
    // Attributes available to this derive:
    #[cel_cxx]
}
Available on crate feature derive only.
Expand description

Derive macro for prost-generated protobuf types.

Generates TypedValue, IntoValue, FromValue, From<T> for Value, and TryFrom<Value> implementations using prost serialization.

§Requirements

The type must implement prost::Message and prost::Name. Enable prost::Name generation via .enable_type_names() in prost-build.

§Attributes

  • type_name = "...": Override the protobuf type name (default: prost::Name::full_name()).
  • crate = ...: Custom path to the cel_cxx crate.

§Setup

In your build.rs, inject the derive via type_attribute():

// build.rs
prost_build::Config::new()
    .enable_type_names()
    .type_attribute("my.package.MyMessage", "#[derive(::cel_cxx::ProstValue)]")
    .compile_protos(&["proto/my.proto"], &["proto/"])
    .unwrap();