Skip to main content

cgp-serde v0.1.0

This page lists what the first release of cgp-serde provides. cgp-serde rebuilds Serde's Serialize and Deserialize traits as components of Context-Generic Programming (CGP), a Rust library whose macros generate traits and their wiring. Serde lets each type fix its encoding once; cgp-serde lets each application choose it.

Released on 2025-11-01.

Summary​

Two components, CanSerializeValue and CanDeserializeValue, move Serde's Self into a Value parameter. The implementing type is then a context, which picks a provider for each value type. On top of them the release ships providers that would overlap as blanket impls of Serde's traits, encodings for bytes and dates, a JSON layer over serde_json, and components that let a deserializer allocate borrowed values in an arena the context holds.

Compatibility​

  • Minimum Rust version: 1.90.
  • CGP version: requires cgp 0.6.
  • Crates: cgp-serde, cgp-serde-extra, cgp-serde-json, cgp-serde-alloc, and cgp-serde-typed-arena, all at 0.1.0.

Upgrading​

This is the library's first release, so there is nothing to upgrade from. Add cgp-serde beside cgp, with the other crates whose providers your wiring names.

New features​

Components​

  • CanSerializeValue<Value> writes a Value to a Serde Serializer with the context as &self; its provider trait is ValueSerializer, and Value may be unsized. See the reference.
  • CanDeserializeValue<'de, Value> reads a Value from a Serde Deserializer with the context as &self; its provider trait is ValueDeserializer.
  • UseDelegate dispatch: both components declare derive_delegate: UseDelegate<Value>, so a context wires one provider per value type through a UseDelegate table.
  • CanAlloc<'a, T>, in cgp-serde-alloc, moves a value into storage that lives for 'a and returns a reference to it; its provider trait is Allocator. See CanAlloc.
  • HasArena<'a, T>, in cgp-serde-typed-arena, is a getter for a typed_arena::Arena<T> on the context, with UseDelegate<T> dispatch.

Context adapters​

  • SerializeWithContext pairs a context with a value and implements Serde's Serialize through the context's CanSerializeValue, so any Serde format can write the value.
  • DeserializeWithContext implements Serde's DeserializeSeed through the context's CanDeserializeValue.

Providers in cgp-serde​

Providers in the other crates​


An AI agent wrote this page from the release's source changes and the CGP knowledge base. Its content was verified against the library's source at the release's tag. See How AI is used in this project.