Macro impl_serde_as_binary_envelope

Source
macro_rules! impl_serde_as_binary_envelope {
    ($adaptor:ident, $extension_reg:expr) => { ... };
}
Expand description

Implements serde_with::DeserializeAs and serde_with::SerializeAs for the helper to deserialize Hugr and Package types, using the given extension registry.

This macro is used to implement the default AsBinaryEnvelope wrapper.

§Parameters

  • $adaptor: The name of the adaptor type to implement.
  • $extension_reg: A reference to the extension registry to use for deserialization.

§Examples

struct CustomAsEnvelope;

impl_serde_as_binary_envelope!(CustomAsEnvelope, &hugr_core::extension::EMPTY_REG);

#[serde_as]
#[derive(Deserialize, Serialize)]
struct A {
    #[serde_as(as = "CustomAsEnvelope")]
    package: Package,
}