View Source EctoIPRange.IPRange (Ecto IP Range v0.2.0)

Struct for PostgreSQL :iprange fields.

Usage

When used during a changeset cast the following values are accepted:

  • :inet.ip4_address(): an IP4 tuple, e.g. {127, 0, 0, 1} (single address only)
  • :inet.ip6_address(): an IP6 tuple, e.g. {8193, 3512, 34211, 0, 0, 35374, 880, 29492} (single address only)
  • binary
    • "127.0.0.1": single address
    • "127.0.0.0/24": CIDR notation for a range from 127.0.0.0 to 127.0.0.255
    • "127.0.0.1-127.0.0.2": arbitrary range
    • "2001:0db8:85a3:0000:0000:8a2e:0370:7334": single address
    • "2001:0db8:85a3:0000:0000:8a2e:0370:0000/112": CIDR notation for a range from 2001:0db8:85a3:0000:0000:8a2e:0370:0000 to 2001:0db8:85a3:0000:0000:8a2e:0370:ffff
    • "2001:0db8:85a3:0000:0000:8a2e:0370:7334-2001:0db8:85a3:0000:0000:8a2e:0370:7335": arbitrary range
  • EctoIPRange.IPRange.t(): a pre-casted struct

Fields

  • range
  • first_ip
  • last_ip

Link to this section Summary

Functions

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.

Link to this section Types

Specs

t() :: %EctoIPRange.IPRange{
  first_ip: :inet.ip4_address() | :inet.ip6_address(),
  last_ip: :inet.ip4_address() | :inet.ip6_address(),
  range: binary()
}

Link to this section Functions

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.