Skip to content

Protobuf Decoder

mosaicolabs.bridges.mcap.decoders.protobuf.rules_matcher

ProtobufRulesMatcher

from_descriptor classmethod

from_descriptor(descr)

Walks descr's fields (recursing into nested messages) and returns a dict mapping each field's RulePath to the ordered list of PROTOBUF_RULES entries whose predicate matches that field (see match_rules) — a field can match more than one, e.g. a Timestamp field that is also a oneof member matches is_field_timestamp, is_field_oneof and is_field_singular_message. MCAPMsgDecoderBase._postprocess() applies them in this same order.

is_field_int64

is_field_int64(field)

Whether field is one of the int64-family protobuf types that need coercion into a native Python int.

is_field_any

is_field_any(field)

Whether field is a google.protobuf.Any message field.

is_field_timestamp

is_field_timestamp(field)

Whether field is a google.protobuf.Timestamp message field.

is_field_oneof

is_field_oneof(field)

Whether field is a member of a oneof group.

is_field_nested

is_field_nested(field)

Whether field holds a nested message (or group) that should be recursed into.

is_field_singular_message

is_field_singular_message(field)

Whether field is a non-repeated message field. Like oneof members, such fields have explicit presence, so always_print_fields_with_no_presence doesn't force MessageToDict to print them when unset (unlike repeated/map fields, which have no presence and are always printed).

is_field_map

is_field_map(field)

Whether field is a protobuf map<K, V> field. Maps are implemented as a repeated field of a synthesized MapEntry message (with key/value fields), so this must be checked before treating a repeated field as an ordinary list.

is_field_bytes

is_field_bytes(field)

Whether field is a protobuf bytes field.

mosaicolabs.bridges.mcap.decoders.MCAPProtobufMsgDecoder

MCAPProtobufMsgDecoder()

Bases: MCAPMsgDecoderBase[Message]

supported_encoding classmethod

supported_encoding()

The channel.message_encoding value this decoder handles (e.g. "protobuf").

decode

decode(decoded_msg)

Turns decoded_msg produced by iter_decoded_messages() of mcap.reader into a plain dictionary after checking that the passed message encoding is supported by the decoder.

register_schema

register_schema(schema)

Registers schema's protobuf FileDescriptorSet into the pool so messages of this type can be decoded during iteration, then computes the per-field postprocessors this schema needs for PyArrow compliance. Skips schemas already registered in the pool.