View Source locus_mmdb_metadata (locus v2.3.6)

API for working with MMDB - metadata

Link to this section Summary

Functions

Parses and validates Metadata out of EncodedDatabase

Link to this section Types

Link to this type

binary_format_version/0

View Source

Specs

binary_format_version() :: {2, locus_mmdb_data:uint16()}.
{Major, Minor}
Link to this type

parse_or_validation_error/0

View Source

Specs

parse_or_validation_error() ::
    {marker_not_found, bitstring()} |
    {atom(), term(), list()} |
    {not_a_map, term()} |
    {incompatible_binary_format_version,
     {locus_mmdb_data_raw:uint16(), locus_mmdb_data_raw:uint16()}} |
    {invalid_binary_format_minor_version, term()} |
    {invalid_binary_format_major_version, term()} |
    {missing_metadata_keys, [unicode:unicode_binary(), ...]} |
    {invalid_node_count, locus_mmdb_data_raw:value()} |
    {missing_node_count, locus_mmdb_data_raw:map_()} |
    {invalid_record_size, locus_mmdb_data_raw:value()} |
    {missing_record_size, locus_mmdb_data_raw:map_()} |
    {invalid_ip_version, locus_mmdb_data_raw:value()} |
    {missing_ip_version, locus_mmdb_data_raw:map_()} |
    {invalid_database_type, locus_mmdb_data_raw:value()} |
    {missing_database_type, locus_mmdb_data_raw:map_()} |
    {languages_not_an_array, locus_mmdb_data_raw:value()} |
    {bad_languages,
     {language_number, pos_integer(), not_an_utf8_string, locus_mmdb_data_raw:value()}} |
    {description_not_a_map, locus_mmdb_data_raw:value()} |
    {bad_description,
     {for_language_code,
      unicode:unicode_binary(),
      {not_an_utf8_string, locus_mmdb_data_raw:value()}}}.

Specs

t() ::
    #{binary_format_version := binary_format_version(),
      node_count := locus_mmdb_data:uint32(),
      record_size := locus_mmdb_data:uint16(),
      ip_version := 4 | 6,
      database_type := locus_mmdb_data:utf8_string(),
      languages => [locus_mmdb_data:utf8_string()],
      build_epoch := locus_mmdb_data:uint64(),
      description => #{locus_mmdb_data:utf8_string() => locus_mmdb_data:utf8_string()},
      {'$_unrecognized_properties'} =>
          #{locus_mmdb_data:utf8_string() := locus_mmdb_data_raw:value()}}.

Link to this section Functions

Link to this function

parse_and_validate(EncodedDatabase)

View Source

Specs

parse_and_validate(EncodedDatabase) -> {ok, Metadata, TreeAndDataSection} | {error, Reason}
                      when
                          EncodedDatabase :: binary(),
                          Metadata :: t(),
                          TreeAndDataSection :: binary(),
                          Reason :: parse_or_validation_error().

Parses and validates Metadata out of EncodedDatabase

To proceed further with TreeAndDataSection, see locus_mmdb:unpack_tree_data_and_data_section/2.