pub trait LinkModel {
// Required methods
fn id(&self) -> i32;
fn start_pin_id(&self) -> i32;
fn end_pin_id(&self) -> i32;
// Provided methods
fn color(&self) -> Color { ... }
fn line_width(&self) -> f32 { ... }
fn status(&self) -> i32 { ... }
}Expand description
Trait for link data to support graph topology and rendering operations.
Implement this trait for your link data type to use with crate::LinkManager
and other graph operations.
§Example
use slint::Color;
use slint_node_editor::LinkModel;
struct MyLink {
id: i32,
from: i32,
to: i32,
color: Color,
width: f32,
label: String, // custom field
}
impl LinkModel for MyLink {
fn id(&self) -> i32 { self.id }
fn start_pin_id(&self) -> i32 { self.from }
fn end_pin_id(&self) -> i32 { self.to }
fn color(&self) -> Color { self.color }
fn line_width(&self) -> f32 { self.width }
}Required Methods§
Sourcefn start_pin_id(&self) -> i32
fn start_pin_id(&self) -> i32
Pin ID where the link starts (typically an output pin)
Sourcefn end_pin_id(&self) -> i32
fn end_pin_id(&self) -> i32
Pin ID where the link ends (typically an input pin)
Provided Methods§
Sourcefn color(&self) -> Color
fn color(&self) -> Color
Color for rendering the link (default: white).
Used as fallback when status() returns -1 (no status).
Sourcefn line_width(&self) -> f32
fn line_width(&self) -> f32
Line width in pixels for rendering the link (default: 2.0)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl LinkModel for LinkData
The Slint LinkData row is the canonical link type, so the library
implements LinkModel for it directly.
Before node-editor.slint was compiled as a library module, LinkData was
generated separately into each consumer crate and every consumer wrote this
impl itself. Now the type is ours, so the orphan rule puts the impl here —
and consumers stop repeating it.