# gizmodel/sql/types/inet

PostgreSQL's network address types inet and cidr as PostgreSQL 16's network.c and inet_net_pton.c read, write and compare them. A value is the text of its canonical output; the binder sends each operator and function of these types to inetApply, which reads the text again.

```gizlang
import * as Inet from "gizmodel/sql/types/inet";
```

## Functions

### `inetKindOf`

```gizlang
function inetKindOf(declared: string): string
```

The network type a declared type names, lower case, or "".

Effects: fail, alloc.

### `inetFunction`

```gizlang
function inetFunction(name: string): bool
```

The functions of inet and cidr values that inetApply evaluates.

Effects: fail, alloc.

### `inetResultOf`

```gizlang
function inetResultOf(op: string): string
```

The declared type of inetApply's result for `op`: INET, CIDR, TEXT, INTEGER, BIGINT or BOOLEAN.

### `inetInput`

```gizlang
function inetInput(kind: string, text: string): string throws DbError
```

Reads `text` as a value of `kind` (inet or cidr) and returns its canonical text (network_in).

Effects: fail, alloc.

### `inetApply`

```gizlang
function inetApply(op: string, args: Vec<Value>): Value throws DbError
```

The operator or function `op` (inetResultOf names its result) of inet and cidr values; a null argument gives null.

Effects: fail, alloc.

### `inetBinary`

```gizlang
function inetBinary(text: string, cidr: bool): Option<bytes>
```

The binary form of a value (inet_send): family, mask length, whether cidr, address length, address bytes.

Effects: fail, alloc.

### `macKindOf`

```gizlang
function macKindOf(declared: string): string
```

The MAC address type a declared type names, lower case, or "".

Effects: fail, alloc.

### `netKindOf`

```gizlang
function netKindOf(declared: string): string
```

The network or MAC address type a declared type names, lower case, or "".

Effects: fail, alloc.

### `macResultOf`

```gizlang
function macResultOf(op: string, kind: string): string
```

The declared type of macApply's result for `op`.

Effects: fail, alloc.

### `macApply`

```gizlang
function macApply(op: string, kind: string, args: Vec<Value>): Value throws DbError
```

The operator, function or cast `op` of MAC addresses of type `kind`: ~ & | trunc set7bit, the comparisons and the
casts macaddr and macaddr8. Text arguments read as `kind`; a null argument gives null.

Effects: fail, alloc.

