thrift_runtime_native (thrift_runtime v0.8.0)

View Source

EEP-79 native records for the representation axis (thrift_runtime:repr() value native).

Native records exist from OTP 29 on, while this runtime keeps minimum_otp_vsn on 28, so every reference to the records module and to the is_record/1 BIF lives behind a -if(?OTP_RELEASE >= 29) conditional: older releases compile the stub branch, where is_native/1 answers false and the conversions raise native_records_unsupported. The facade turns the gate into {error, {unsupported_repr, native}} before any conversion runs.

The runtime never compiles record definitions: values are minted with records:create/4 from the wire field map (all declared fields present, missing wire fields as undefined), stamped with the descriptor's module and the lowercased struct name — the same tag a tuple record of that struct carries. Values are created exported, since they are handed out of the module that decoded them.

Summary

Functions

Creates an exported native record Module:Name with the given {FieldAtom, Value} pairs (every declared field, in declaration order).

The identity and content of a native record: its module, its name and the FieldAtom => Value map over all its fields.

Answers whether Term is a native record of any definition.

Answers whether this OTP carries native records (EEP-79, OTP 29+).

Types

native_record()

-opaque native_record()

Functions

create(Module, Name, FieldValues)

-spec create(module(), atom(), [{atom(), term()}]) -> native_record().

Creates an exported native record Module:Name with the given {FieldAtom, Value} pairs (every declared field, in declaration order).

fields(Record)

-spec fields(native_record()) -> {module(), atom(), #{atom() => term()}}.

The identity and content of a native record: its module, its name and the FieldAtom => Value map over all its fields.

is_native(Term)

-spec is_native(term()) -> boolean().

Answers whether Term is a native record of any definition.

supported()

-spec supported() -> boolean().

Answers whether this OTP carries native records (EEP-79, OTP 29+).