It is useful in some applications to get a snapshot of the stream
management state for storage outside the process, in order to recover
from crashes and other things. The get_sm_state already present is not
suitable for this because it returns a live object tied in to the
current context and such, and containing much unneeded internal-api
data.
Introduce xmpp_sm_state_set_callback which is called every time the
state changes with a serialized state, and a dual xmpp_sm_state_restore
which takes in this serialized state and sets up a new sm_state based on
that.
The serialization is considered opaque from the PoV of the API, but is
based on CBOR to facilitate easy debugging.