Skip to Content

Saved state

Learn how a session keeps bind keys and tokens so your app never tracks pairing.

Many watches bind once and log in on every later connect, with keys or tokens from the bind. A session keeps that in a small saved-state blob instead of asking your app to understand it.

Store it

  • Call saved_state() after each handle call. When it returns bytes that differ from what you hold, store them for this watch.
  • Store them whenever they change, even if the sync later fails: a completed bind must not be lost.
  • Pass the bytes to the next session's constructor for the same watch.

When it is rejected

If a constructor fails with InvalidSavedState, the bytes are not a state this driver saved. Forget them and connect without, which starts a fresh bind on watches that need one.

What it holds

It depends on the protocol: a bind key, a login token or a sync checkpoint, for example. Treat it as opaque bytes and keep it per watch, not per user.

See also

On this page