Type adapter for protobuf-elixir generated message structs.
This module is only compiled when the protobuf library is available.
Enables CEL expressions to work with protobuf messages seamlessly:
- Field access via dot notation (msg.field_name)
- has() checks for field presence (respects proto3 field presence)
- Automatic conversion of well-known types (Timestamp, Duration, wrappers)
Usage
defmodule MyProto.User do
use Protobuf, syntax: :proto3
field :name, 1, type: :string
field :age, 2, type: :int32
end
env = Celixir.Environment.new(%{user: %MyProto.User{name: "alice", age: 30}})
|> Celixir.Environment.set_type_adapter(Celixir.ProtobufAdapter)
Celixir.eval!("user.name == 'alice'", env)