Skip to main content

LinkModel

Trait LinkModel 

Source
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§

Source

fn id(&self) -> i32

Unique identifier for the link

Source

fn start_pin_id(&self) -> i32

Pin ID where the link starts (typically an output pin)

Source

fn end_pin_id(&self) -> i32

Pin ID where the link ends (typically an input pin)

Provided Methods§

Source

fn color(&self) -> Color

Color for rendering the link (default: white). Used as fallback when status() returns -1 (no status).

Source

fn line_width(&self) -> f32

Line width in pixels for rendering the link (default: 2.0)

Source

fn status(&self) -> i32

Computation status for the link (default: -1 = no status, use color field). When >= 0, the Slint side resolves the color from LinkStatusColors. Standard values: -1=none, 0=idle, 1=running, 2=succeeded, 3=failed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

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.