Sidereon.CCSDS.TDM.Metadata (Sidereon v3.0.0)

Copy Markdown View Source

Metadata block for one TDM segment.

fields holds the block's KEY = value assignments in order, and is the block's authority. participants, mode, paths, timetag_ref, time_system and range_units are derived from it: read them, but change a block through from_raw/2, from_raw_with_policy/3, replace_raw/3 or replace_raw_with_policy/4, which validate the fields and derive every property from them in one step. The encoders refuse a block whose derived properties disagree with its fields as {:metadata_not_derived, %{segment, property}}.

comments holds the block's comments, each with the index of the field it precedes.

range_units is "km" when the block states no RANGE_UNITS.

Summary

Functions

Build a metadata block from its ordered raw fields and positioned comments under the strict writer policy.

Build a metadata block from its ordered raw fields and positioned comments under a writer policy.

Replace a block's raw fields and comments under the strict writer policy.

Replace a block's raw fields and comments under a writer policy.

Types

t()

@type t() :: %Sidereon.CCSDS.TDM.Metadata{
  comments: [Sidereon.CCSDS.TDM.Comment.t()],
  fields: [Sidereon.CCSDS.TDM.Field.t()],
  mode: String.t() | nil,
  participants: [Sidereon.CCSDS.TDM.Participant.t()],
  paths: [Sidereon.CCSDS.TDM.Path.t()],
  range_units: String.t(),
  time_system: String.t() | nil,
  timetag_ref: String.t() | nil
}

Functions

from_raw(fields, comments)

@spec from_raw([Sidereon.CCSDS.TDM.Field.t()], [Sidereon.CCSDS.TDM.Comment.t()]) ::
  {:ok, t()} | {:error, term()}

Build a metadata block from its ordered raw fields and positioned comments under the strict writer policy.

The fields are held to table 3-3's keywords, order and mandatory entries, single value assignment and path participant references, and the comments to positions the writer can emit unchanged; every derived property comes from the fields. Returns {:ok, %Metadata{}} or {:error, {tag, fields}} as Sidereon.CCSDS.TDM lists them; a segment-specific refusal names segment 1.

from_raw_with_policy(fields, comments, policy)

@spec from_raw_with_policy(
  [Sidereon.CCSDS.TDM.Field.t()],
  [Sidereon.CCSDS.TDM.Comment.t()],
  Sidereon.CCSDS.TDM.WritePolicy.t() | keyword() | map()
) ::
  {:ok, %{value: t(), departures: [Sidereon.CCSDS.TDM.Departure.t()]}}
  | {:error, term()}

Build a metadata block from its ordered raw fields and positioned comments under a writer policy.

policy is a Sidereon.CCSDS.TDM.WritePolicy, or a keyword list or map of its axes. Returns {:ok, %{value: metadata, departures: departures}}, every forgiven departure listed as a Sidereon.CCSDS.TDM.Departure, or {:error, reason}. What no policy forgives, such as conflicting keywords or an undefined path participant, is refused under every policy.

replace_raw(metadata, fields, comments)

@spec replace_raw(t(), [Sidereon.CCSDS.TDM.Field.t()], [
  Sidereon.CCSDS.TDM.Comment.t()
]) ::
  {:ok, t()} | {:error, term()}

Replace a block's raw fields and comments under the strict writer policy.

The replacement is atomic: on success every field, comment and derived property is the new one; on refusal nothing is replaced and the refusal is returned. Returns {:ok, %Metadata{}} or {:error, reason} as from_raw/2.

replace_raw_with_policy(metadata, fields, comments, policy)

@spec replace_raw_with_policy(
  t(),
  [Sidereon.CCSDS.TDM.Field.t()],
  [Sidereon.CCSDS.TDM.Comment.t()],
  Sidereon.CCSDS.TDM.WritePolicy.t() | keyword() | map()
) ::
  {:ok, %{value: t(), departures: [Sidereon.CCSDS.TDM.Departure.t()]}}
  | {:error, term()}

Replace a block's raw fields and comments under a writer policy.

Atomic as replace_raw/3. Returns {:ok, %{value: metadata, departures: departures}} or {:error, reason} as from_raw_with_policy/3.