pub trait LinkValidator<N = SimpleNodeGeometry, L = ()> {
// Required method
fn validate(
&self,
start_pin: i32,
end_pin: i32,
cache: &GeometryCache<N>,
links: &[L],
) -> ValidationResult;
}Expand description
Trait for custom link validation logic.
Implement this to add custom validation rules for connecting pins.
Pass topology rules to validate_and_normalize_link directly or compose
several rules with CompositeValidator.
The trait is generic over:
N: The node geometry type (defaults toSimpleNodeGeometry)L: The link type for accessing existing links (must implementLinkModel)
§Example
use slint_node_editor::{
GeometryCache, LinkValidator, NodeGeometry, ValidationResult,
};
struct MyValidator;
impl<N, L> LinkValidator<N, L> for MyValidator
where
N: NodeGeometry + Copy,
{
fn validate(
&self,
start_pin: i32,
end_pin: i32,
_cache: &GeometryCache<N>,
_links: &[L],
) -> ValidationResult {
// Custom validation logic
ValidationResult::Valid
}
}Required Methods§
Sourcefn validate(
&self,
start_pin: i32,
end_pin: i32,
cache: &GeometryCache<N>,
links: &[L],
) -> ValidationResult
fn validate( &self, start_pin: i32, end_pin: i32, cache: &GeometryCache<N>, links: &[L], ) -> ValidationResult
Check if a link between two pins is valid
§Arguments
start_pin- ID of the starting pinend_pin- ID of the ending pincache- Geometry cache for pin informationlinks- Slice of existing links for duplicate/fan-out checks
§Returns
ValidationResult::Valid if the link is allowed,
ValidationResult::Invalid(reason) otherwise
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".