serde_context 0.1.0

Convenient contextful (de)serialization compatible with the serde ecosystem
Documentation

Serde Context

Convenient contextful (de)serialization compatible with the serde ecosystem.

You can find examples in the this crate's examples directory.

Limitations

There are a few limitations to this crate:

  • Only immutable references may be passed as context. You may still use interior mutability (Cells, RefCells, UnsafeCells...) to mutate state.
  • Only types implementing 'static can be used as context for (de)serialization. Unsized types are supported, though.
  • There is no type-checking of required context. Trying to (de)serialize a type that requires some context but failing to provide it will result in a runtime error.

Alternatives

There are a few alternatives to this crate you might want to consider, each with their pros and cons:

  • DeserializeSeed: the official serde stateful deserialization-only API. Requires implementing that trait for each type you are interested in deserializing, and no derive macro is provided (nor are there any plans to ever make an official one).
  • serde_state: a fork of serde that supports stateful (de)serialization. Unfortunately, it looks to be unmaintained.
  • serde_seeded: a crate providing an alternative version of the DeserializeSeed trait with a derive macro for it. Relatively young but very promising.

License