---
title: "encode(to:)"
framework: os
role: symbol
role_heading: Instance Method
path: "os/ossignpostintervalstate/encode(to:)"
---

# encode(to:)

Encodes the interval state into the provided encoder.

## Declaration

```swift
func encode(to encoder: any Encoder) throws
```

## Parameters

- `encoder`: The encoder to write data to.

## Discussion

Discussion important: You don’t call this method directly. Instead, the object you’re using to encode the interval state, which must adopt the Encoder protocol, calls it on your behalf as part of the serialization process. The method throws an error if the interval state is invalid for the specified encoder’s format.
