# `GRPC.Codec`
[🔗](https://github.com/elixir-grpc/grpc_core/blob/v1.0.5/lib/grpc/codec.ex#L1)

Contains code to serialize a deserialize the message.

# `decode`

```elixir
@callback decode(any(), module :: atom()) :: any()
```

# `encode`

```elixir
@callback encode(any(), opts :: keyword()) :: iodata()
```

Encodes a value to iodata.

Optionally accepts a keyword list of options for customizing the encoding behavior.

# `name`

```elixir
@callback name() :: String.t()
```

Name is identity of the codec, which will be suffix after content-type "application/grpc+" such as "proto".

# `pack_for_channel`
*optional* 

```elixir
@callback pack_for_channel(iodata()) :: binary()
```

This function is invoked whenever it is defined after the protobuf message has been transformed into a gRPC payload.

This can be used to apply a transform over the gRPC message before sending it.
For instance grpc-web using the `application/grpc-web-text` content type requires the message to be Base64-encoded, so a server sending messages using grpc-web-text will be required to
do a Base64 encode on the payload before sending the gRPC message.

# `unpack_from_channel`
*optional* 

```elixir
@callback unpack_from_channel(binary()) :: binary()
```

This function is invoked before the gRPC payload is transformed into a protobuf message whenever it is defined.

This can be used to apply a transform over the gRPC message before decoding it. For instance grpc-web using the `application/grpc-web-text`
content type requires the message to be Base64-encoded, so a server receiving messages using grpc-web-text will be required to
do a Base64 decode on the payload before decoding the gRPC message.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
