Module descriptor_pool

Module descriptor_pool 

Source
Expand description

Dynamic message pool for runtime schema handling.

The DescriptorPool allows decoding and encoding protobuf messages when the schema is only known at runtime. It builds lookup tables from FileDescriptorProto messages, enabling dynamic operations without generated code.

§Use Cases

  • Generic protobuf processors (proxies, loggers, transformers)
  • Schema-driven tools that load .proto definitions at runtime
  • Testing and debugging tools

§Example

use protocrap::{ProtobufRef, arena::Arena, descriptor_pool::DescriptorPool};
use protocrap::google::protobuf::FileDescriptorProto;
use allocator_api2::alloc::Global;

// Build pool from file descriptors
let mut pool = DescriptorPool::new(&Global);
let file_desc = FileDescriptorProto::ProtoType::file_descriptor();
pool.add_file(file_desc);

// Decode a message dynamically
let bytes = file_desc.encode_vec::<32>().unwrap();
let mut arena = Arena::new(&Global);
let msg = pool.decode_message(
    "google.protobuf.FileDescriptorProto",
    &bytes,
    &mut arena,
).unwrap();

// Inspect fields
println!("{:?}", msg);

Modules§

test_util

Structs§

DescriptorPool
A registry of message types for dynamic protobuf operations.