Flatbuf.Schema (flatbuf v0.1.0)

Copy Markdown View Source

Resolved FlatBuffers schema IR.

A %Flatbuf.Schema{} is the single source of truth for code generation. It contains every type that was parsed (across include files), keyed by its fully-qualified name, plus the root_type / file_identifier / file_extension declarations.

Type records live in sibling modules: Flatbuf.Schema.Table, Flatbuf.Schema.Struct, Flatbuf.Schema.Enum, and Flatbuf.Schema.Field.

Summary

Functions

Return all enums in the schema, in stable order by FQN.

Return the type record for a fully-qualified name, or nil if not found.

Default value used when a missing scalar field is decoded.

Byte size of a scalar kind.

Return all structs in the schema, in stable order by FQN.

Return all tables in the schema, in stable order by FQN.

Return all unions in the schema, in stable order by FQN.

Types

scalar()

@type scalar() ::
  :bool | :u8 | :u16 | :u32 | :u64 | :i8 | :i16 | :i32 | :i64 | :f32 | :f64

t()

@type t() :: %Flatbuf.Schema{
  file_extension: String.t() | nil,
  file_identifier: String.t() | nil,
  root_type: String.t() | nil,
  source_files: [String.t()],
  types: %{required(String.t()) => type_record()}
}

type_record()

type_spec()

@type type_spec() ::
  {:scalar, scalar()}
  | :string
  | {:vector, type_spec()}
  | {:array, type_spec(), pos_integer()}
  | {:name, String.t()}
  | {:table, String.t()}
  | {:struct, String.t()}
  | {:enum, String.t()}
  | {:union, String.t()}

Functions

enums(schema)

@spec enums(t()) :: [Flatbuf.Schema.Enum.t()]

Return all enums in the schema, in stable order by FQN.

fetch(schema, fqn)

@spec fetch(t(), String.t()) :: type_record() | nil

Return the type record for a fully-qualified name, or nil if not found.

scalar_default(arg1)

@spec scalar_default(scalar()) :: number() | boolean()

Default value used when a missing scalar field is decoded.

scalar_size(atom)

@spec scalar_size(scalar()) :: 1 | 2 | 4 | 8

Byte size of a scalar kind.

structs(schema)

@spec structs(t()) :: [Flatbuf.Schema.Struct.t()]

Return all structs in the schema, in stable order by FQN.

tables(schema)

@spec tables(t()) :: [Flatbuf.Schema.Table.t()]

Return all tables in the schema, in stable order by FQN.

unions(schema)

@spec unions(t()) :: [Flatbuf.Schema.Union.t()]

Return all unions in the schema, in stable order by FQN.