Skip to main content

GestureData

Trait GestureData 

Source
pub trait GestureData: Copy + 'static {
    // Required method
    unsafe fn read(at: *const u8) -> Self;
}
Expand description

What a gesture hands its handlers, as a Rust type.

The gesture’s own type decides this — a drag reports a DragValue, a long press a bool — so a handler’s argument follows from the gesture it is attached to rather than being a case anyone has to match on.

Implemented per type rather than derived: reading the bytes SwiftUI passes is a decision about that Gesture.Value’s layout.

Required Methods§

Source

unsafe fn read(at: *const u8) -> Self

Read the value SwiftUI passed by address.

§Safety

at must point at a live Gesture.Value of the matching Swift type.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl GestureData for ()

Source§

unsafe fn read(_: *const u8) -> Self

Source§

impl GestureData for bool

Source§

unsafe fn read(at: *const u8) -> Self

LongPressGesture.Value — one byte, true once the press completes.

Source§

impl GestureData for f64

Source§

unsafe fn read(at: *const u8) -> Self

MagnifyGesture.Value and RotateGesture.Value both lead with the scalar the gesture is about — a magnification, or an angle in radians.

Implementors§