Skip to main content

Crate obs_build

Crate obs_build 

Source
Expand description

Build-time codegen helpers for the proto-first authoring path.

Phase-1 surface (impl-plan task 1.10):

  • Config::compile runs protoc (or accepts a precompiled FDS), hands the FDS to buffa-build for Rust-type generation, then walks the FDS via buffa-reflect to extract the (obs.v1.event) and (obs.v1.field) custom options out of each message’s MessageOptions.__buffa_unknown_fields. From those bytes the codegen emits EventSchema impls, EventSchemaErased impls, and linkme registrations into OUT_DIR/obs/schemas.rs.
  • The byte-identical-output property described in spec 12 § 1.2 (proto-first vs Rust-first land on the same generated bytes when the schemas are equivalent) is verified via Phase-2 task 2.1 integration tests; Phase 1 ships the codegen, the test harness builds on top.

See spec 12 § 4 + spec 14 § 7.

Re-exports§

pub use lints::LintError;
pub use lints::LintField;
pub use lints::LintInput;
pub use lints::LintProtoType;
pub use lints::emit_cross_event_lints;
pub use lints::emit_lints;

Modules§

lints
Shared lint emission for the proto-first (obs-build::codegen) and Rust-first (obs-macros::derive_event) authoring paths.
reflect
Reflection-based reader of (obs.v1.event) and (obs.v1.field) options from a buffa-reflect descriptor pool. Re-exported so obs-cli’s lint / validate / schema show subcommands can share the parser with Config::compile.

Structs§

Config
Build-script entry point.
EventOptions
Decoded (obs.v1.event) payload.
FieldOptions
Decoded (obs.v1.field) payload.
MetricSpec
Decoded (obs.v1.MetricSpec).

Enums§

CodegenError
Errors returned by the option scanner.
DescriptorSource
Source of the FileDescriptorSet. Spec 12 § 4.

Constants§

EMBEDDED_ENUMS_PROTO
Embedded canonical text of obs/v1/enums.proto, re-exported for the same reason as EMBEDDED_OPTIONS_PROTO.
EMBEDDED_OPTIONS_PROTO
Embedded canonical text of obs/v1/options.proto, re-exported so downstream consumers (e.g. obs-cli’s schema_source) can reuse it without re-vendoring.

Functions§

materialise_embedded_options
Write the embedded obs/v1/{options,enums}.proto pair into {dir}/obs/v1/ so a downstream protoc invocation can include them. Used by both Config::compile above and obs-cli’s schema-source helper.