pub struct CompositeValidator<N = SimpleNodeGeometry, L = ()> { /* private fields */ }Expand description
Composite validator that combines multiple validators
All validators must return Valid for the link to be valid (AND logic). Returns the first error encountered (short-circuits on failure).
Note: Uses Vec<Box<dyn ...>> which allocates. For zero-allocation
validation, chain validators manually using ValidationResult::and().
§Example
use slint_node_editor::{
BasicLinkValidator, CompositeValidator, GeometryCache, LinkValidator,
NoDuplicatesValidator, SimpleLink, SimpleNodeGeometry,
};
let mut cache = GeometryCache::<SimpleNodeGeometry>::new();
cache.update_node_rect(1, 0.0, 0.0, 100.0, 60.0);
cache.update_node_rect(2, 200.0, 0.0, 100.0, 60.0);
cache.handle_pin_report(3, 1, 2, 100.0, 30.0);
cache.handle_pin_report(4, 2, 1, 0.0, 30.0);
let links = Vec::<SimpleLink>::new();
let validator = CompositeValidator::new().with(NoDuplicatesValidator);
let normalized = slint_node_editor::validate_and_normalize_link(
4, 3, &cache, &links, 2, &validator,
).unwrap();
assert_eq!((normalized.output_pin_id, normalized.input_pin_id), (3, 4));Implementations§
Source§impl<N, L> CompositeValidator<N, L>
impl<N, L> CompositeValidator<N, L>
Sourcepub fn with<V: LinkValidator<N, L> + 'static>(self, validator: V) -> Self
pub fn with<V: LinkValidator<N, L> + 'static>(self, validator: V) -> Self
Add a validator to the composite
Validators are checked in the order they were added. The first validator to return Invalid will short-circuit.
Trait Implementations§
Source§impl<N, L> Default for CompositeValidator<N, L>
impl<N, L> Default for CompositeValidator<N, L>
Source§impl<N, L> LinkValidator<N, L> for CompositeValidator<N, L>
impl<N, L> LinkValidator<N, L> for CompositeValidator<N, L>
Source§fn 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 Read more
Auto Trait Implementations§
impl<N = SimpleNodeGeometry, L = ()> !RefUnwindSafe for CompositeValidator<N, L>
impl<N = SimpleNodeGeometry, L = ()> !Send for CompositeValidator<N, L>
impl<N = SimpleNodeGeometry, L = ()> !Sync for CompositeValidator<N, L>
impl<N = SimpleNodeGeometry, L = ()> !UnwindSafe for CompositeValidator<N, L>
impl<N, L> Freeze for CompositeValidator<N, L>
impl<N, L> Unpin for CompositeValidator<N, L>
impl<N, L> UnsafeUnpin for CompositeValidator<N, L>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more