From abfaba611fdc2cdb51d2f9f5d23155cec5aeff14 Mon Sep 17 00:00:00 2001 From: Luca Mondada <72734770+lmondada@users.noreply.github.com> Date: Tue, 5 Sep 2023 15:46:43 +0200 Subject: [PATCH] feat: Port is serializable (#489) I need something like this to be able to serialize pattern matcher in TKET2 (more specifically: to serialize predicates for matching). I'm not sure this is the right approach or you'd rather I expose a different serialization API in HUGR for this purpose. --- src/hugr.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/hugr.rs b/src/hugr.rs index df99e8197..d741ae46d 100644 --- a/src/hugr.rs +++ b/src/hugr.rs @@ -179,7 +179,21 @@ pub struct Node { } /// A handle to a port for a node in the HUGR. -#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash, Default, Debug, From)] +#[derive( + Clone, + Copy, + PartialEq, + PartialOrd, + Eq, + Ord, + Hash, + Default, + Debug, + From, + serde::Serialize, + serde::Deserialize, +)] +#[serde(transparent)] #[cfg_attr(feature = "pyo3", pyclass)] pub struct Port { offset: portgraph::PortOffset,