Thalweg · API reference ← Main docs

Crate twg_proto_schema

Crate twg_proto_schema 

Source
Expand description

Flattens a protobuf message type into an Arrow schema, matching the semantic policies documented in flatten and wrapper. Generic and self-contained: no runtime wire-decode, no product-specific assumptions - just descriptor-to-schema computation.

let bytes = std::fs::read("some_descriptor.pb").unwrap();
let schema = twg_proto_schema::build_arrow_schema(&bytes, "some.package.MyMessage", 2)?;

Enums§

ProtoSchemaError

Constants§

MAX_STRUCT_DEPTH
Default safety limit for constructing a genuine nested Struct / List<Struct> type once something is no longer being flattened into named columns - independent of and unrelated to flatten_depth. Raised from the historical 12 to 64 so realistically-deep schemas type natively rather than collapsing to Utf8; callers that need a different bound pass one explicitly via build_arrow_schema_with_struct_depth.

Functions§

build_arrow_schema
Decodes descriptor_set_bytes as a protobuf FileDescriptorSet (must be compiled with protoc --include_imports so every referenced type is present in the set), resolves message_type (fully-qualified; a leading ‘.’ is added if missing), and flattens its fields into an Arrow schema.
build_arrow_schema_with_struct_depth
build_arrow_schema with an explicit max_struct_depth, the safety limit on native nested-Struct/Map-value recursion before a sub-message falls back to Utf8-JSON. The default (MAX_STRUCT_DEPTH) suits almost every schema; raise it for an unusually deep message graph, lower it to cap decode cost. Distinct from flatten_depth (flat-column expansion).
compile_proto_to_bytes
Compiles one or more .proto files directly to FileDescriptorSet bytes, without needing a protoc binary on PATH - protox parses and resolves .proto syntax itself (pure Rust). Equivalent to protoc --include_imports in that every type reachable from proto_paths (via include_paths) ends up present in the set, which build_arrow_schema (and any decode crate built on top of this) requires.