| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
PostgresqlTypes.Inet
Contents
Synopsis
- data Inet
- fold :: (Word32 -> Word8 -> a) -> (Word32 -> Word32 -> Word32 -> Word32 -> Word8 -> a) -> Inet -> a
- refineToV4 :: Inet -> Maybe (Word32, Word8)
- refineToV6 :: Inet -> Maybe (Word32, Word32, Word32, Word32, Word8)
- normalizeFromV4 :: Word32 -> Word8 -> Inet
- normalizeFromV6 :: Word32 -> Word32 -> Word32 -> Word32 -> Word8 -> Inet
- refineFromV4 :: Word32 -> Word8 -> Maybe Inet
- refineFromV6 :: Word32 -> Word32 -> Word32 -> Word32 -> Word8 -> Maybe Inet
Documentation
PostgreSQL inet type.
Holds an IPv4 or IPv6 host address, and optionally its subnet, all in one field. The subnet is represented by the number of network address bits present in the host address (the “netmask”). If the netmask is 32 and the address is IPv4, then the value does not indicate a subnet, only a single host. In IPv6, the address length is 128 bits, so 128 bits specify a unique host address. Note that if you want to accept only networks, you should use the cidr type rather than inet.
The input format for this type is address/y where address is an IPv4 or IPv6 address and y is the number of bits in the netmask. If the /y portion is omitted, the netmask is taken to be 32 for IPv4 or 128 for IPv6, so the value represents just a single host. On display, the /y portion is suppressed if the netmask specifies a single host.
Instances
| Arbitrary Inet Source # | |
| IsString Inet Source # | |
Defined in PostgresqlTypes.Inet Methods fromString :: String -> Inet # | |
| Read Inet Source # | |
| Show Inet Source # | |
| Eq Inet Source # | |
| Ord Inet Source # | |
| Hashable Inet Source # | |
Defined in PostgresqlTypes.Inet | |
| IsScalar Inet Source # | |
Defined in PostgresqlTypes.Inet Methods schemaName :: Tagged Inet (Maybe Text) # typeName :: Tagged Inet Text # baseOid :: Tagged Inet (Maybe Word32) # arrayOid :: Tagged Inet (Maybe Word32) # typeParams :: Tagged Inet [Text] # typeSignature :: Tagged Inet Text # binaryEncoder :: Inet -> Write # binaryDecoder :: Variable (Either DecodingError Inet) # textualEncoder :: Inet -> TextBuilder # | |
Accessors
Arguments
| :: (Word32 -> Word8 -> a) | Function to handle IPv4 address case. Takes the IPv4 address as |
| -> (Word32 -> Word32 -> Word32 -> Word32 -> Word8 -> a) | Function to handle IPv6 address case. Takes the four 32-bit words of the IPv6 address in big-endian order and the netmask as |
| -> Inet | |
| -> a |
Pattern match on Inet type.
refineToV4 :: Inet -> Maybe (Word32, Word8) Source #
Refine an IPv4 Inet value from a 32-bit address and an 8-bit netmask, both in big-endian order.
refineToV6 :: Inet -> Maybe (Word32, Word32, Word32, Word32, Word8) Source #
Refine an IPv6 Inet value from four 32-bit words representing the address and an 8-bit netmask, all in big-endian order.
Constructors
Arguments
| :: Word32 | IPv4 address as a 32-bit big-endian word. |
| -> Word8 | Network mask length (0-32). |
| -> Inet |
Construct an IPv4 Inet value from a 32-bit address and an 8-bit netmask, both in big-endian order.
The netmask is clamped to be in the range 0-32.
Arguments
| :: Word32 | First 32 bits of IPv6 address in big-endian order. |
| -> Word32 | Second 32 bits of IPv6 address in big-endian order. |
| -> Word32 | Third 32 bits of IPv6 address in big-endian order. |
| -> Word32 | Fourth 32 bits of IPv6 address in big-endian order. |
| -> Word8 | Network mask length (0-128). |
| -> Inet |
Construct an IPv6 Inet value from four 32-bit words representing the address and an 8-bit netmask, all in big-endian order.
The netmask is clamped to be in the range 0-128.