Skip to main content

Recallable

Derive Macro Recallable 

Source
#[derive(Recallable)]
{
    // Attributes available to this derive:
    #[recallable]
}
Expand description

Derive macro that generates the companion memento type and Recallable impl.

The generated memento type:

  • mirrors the original struct shape (named/tuple/unit),
  • includes fields unless marked with #[recallable(skip)],
  • uses the same visibility as the input struct,
  • keeps all generated fields private by omitting field-level visibility modifiers,
  • also derives serde::Deserialize when the serde feature is enabled for the macro crate.

For #[recallable] fields, the generated memento field type is exactly <FieldType as Recallable>::Memento. The macro does not prescribe one canonical container semantics; it uses whatever memento shape the field type defines.

The companion struct itself is generated as an internal implementation detail. The supported way to name it is <Struct as Recallable>::Memento. It is intended to be produced and consumed alongside the source struct, primarily through Recall::recall/TryRecall::try_recall, not as a field-inspection surface with widened visibility.

The Recallable impl sets type Memento to that generated type and adds any required generic bounds.

The generated memento struct always derives Clone, Debug, and PartialEq. When the serde feature is enabled, it also derives serde::Deserialize. All non-skipped field types must implement these derived traits.

To suppress the default Clone, Debug, and PartialEq derives (and their corresponding trait bounds), annotate the struct with #[recallable(skip_memento_default_derives)]. When serde is enabled, Deserialize is still derived on the memento even with this attribute.

When the impl_from feature is enabled for the macro crate, a From<Struct> implementation is also generated for the memento type. For #[recallable] fields, that additionally requires <FieldType as Recallable>::Memento: From<FieldType>.