package mmdb

  1. Overview
  2. Docs

Binding to the maxminddb library which parses the MMDB format commonly known as GeoIP2

type t

Reference to an MMBD file

exception Binding_integrity_error of string

Thrown when an error is detected that is an internal error of the library, not a usage error. It is recommended not to handle this, instead report a bug report in the library

module Common_error : sig ... end
module Open_file_error : sig ... end
module Fetch_ip_data_error : sig ... end
module Fetch_value_error : sig ... end
module Fetch_error : sig ... end
val library_version : string

The version string of the underlying C library

module Path : sig ... end
val open_file : Path.t -> (t, Open_file_error.t) Stdlib.result

Open an MMDB file and return a reference to it

module Version_number : sig ... end
val binary_format_version : t -> Version_number.t

The version number of the binary format in underlying MMDB file

module Language : sig ... end
val languages : t -> Language.t list

Retrieves a list of languages supported by the database

val language_by_code : t -> string -> Language.t option

Retrieves a specific language by its language code

module Ip : sig ... end
type ip_data

An opaque reference to the data structure associated with an IP address

val fetch_ip_data : t -> Ip.t -> (ip_data, Fetch_ip_data_error.t) Stdlib.result

Retrieves the data associated with the supplied IP address

module type VALUE_TYPE = sig ... end

Signatures for handling queries that yield a particular type of answer

type any_value =
  1. | String of string
  2. | Float of float
  3. | Int of int
  4. | Bool of bool

The supported atomic value types that can be retrieved from a database

module Any : VALUE_TYPE with type answer = any_value

Interface to query for values of type any_value. This may come useful in case the database contains different value types at the same query path. Specialized modules for retrieving strings, floats, integers and booleans are available below.

module String : sig ... end

Interface for retrieving string values from the database

module Float : VALUE_TYPE with type answer = float

Interface for retrieving float values from the database

module Int : VALUE_TYPE with type answer = int

Interface for retrieving integer values from the database

module Bool : VALUE_TYPE with type answer = bool

Interface for retrieving boolean values from the database

module Coordinates : sig ... end

Interface for retrieving coordinate values from the database

OCaml

Innovation. Community. Security.