What the host owns
The widget is stateless between frames and never mutates your data model. It renders the nodes and edges you pass in and reports intent through callbacks; your update applies the change and the next view reflects it. Which makes these yours to uphold:
- Unique node ids. Lookups resolve by id, so a duplicate push is ignored (first wins) and debug builds assert on it. Prefer a stable id from your data - a database key,
uuid::Uuid, a typed newtype - over a hand-managed counter. - Edge dedupe.
on_connectfires on every snap during a drag, not on release, so one drag can report several connections. The defaultcan_connectalready rejects a second edge into an occupied input; for replace-on-drop instead, drop that rule (seeconnection) and remove the prior edge whose input matches -tois always the input pin. - Applying moves, deletes and clones.
on_move/on_delete/on_clonereport intent only. - Applying selection. Optional: the widget keeps a working selection, so clicks and the selection box work on their own.
on_selectreports it; to own it, mark the matching nodes withNode::selectedon the nextviewand your value takes over whenever it changes. Selection is a node property, so there is no ordering to get right. The camera is the same story throughon_cameraandcamera.