Ids
Nodes, pins, edges and anchors carry your own id types, and a pin can carry a payload. Those five types are named once, on a marker implementing Ids; Indexed (usize ids, no edge id, no payload) is the default and what node_graph builds. Any type that is Clone + Eq + Hash + Debug + Send + Sync + 'static is an id, so a newtype, an enum or a uuid::Uuid needs no impl.
use iced_nodegraph::{Ids, NodeGraph, PinRef, node};
use iced::{Element, Point};
use iced::widget::text;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
struct AppIds;
impl Ids for AppIds {
type NodeId = u64;
type PinId = &'static str;
type EdgeId = u64;
type AnchorId = usize;
type Payload = ();
}
#[derive(Debug, Clone)]
enum Message {
Connected(PinRef<AppIds>, PinRef<AppIds>),
}
fn view() -> Element<'static, Message> {
NodeGraph::<AppIds, _, _, _>::new()
.on_connect(Message::Connected)
.push_node(node(7, Point::ORIGIN, text("seven")))
.into()
}The marker is the one type the compiler cannot infer, so it is named on the graph and in the messages that carry a PinRef; every builder and callback infers it from there.