#[repr(C)]pub enum HapticPattern {
Show 19 variants
Selection = 0,
ImpactLight = 1,
ImpactMedium = 2,
ImpactHeavy = 3,
ImpactSoft = 4,
ImpactRigid = 5,
Success = 6,
Warning = 7,
Error = 8,
KeyPress = 9,
KeyRelease = 10,
LongPress = 11,
ContextClick = 12,
TextHandleMove = 13,
GestureStart = 14,
GestureEnd = 15,
Rise = 16,
Fall = 17,
Spin = 18,
}Expand description
A haptic pattern to play, named by INTENT rather than by waveform.
See the module docs for the per-platform mapping and for why this names intents instead of envelopes.
Variants§
Selection = 0
A value moved to a new discrete step — a slider hitting a detent, a picker wheel advancing, a segmented control changing. The lightest thing in the vocabulary; safe to fire repeatedly during a drag.
ImpactLight = 1
A small, light collision — a lightweight object landing.
ImpactMedium = 2
A moderate collision. The sensible default for “something happened”.
ImpactHeavy = 3
A large, heavy collision — a heavyweight object landing.
ImpactSoft = 4
A dull, compliant thud — the impact of something soft. Distinguished
from ImpactLight by texture, not strength.
ImpactRigid = 5
A crisp, hard tap — the impact of something inflexible. Distinguished
from ImpactHeavy by texture, not strength.
Success = 6
A task completed successfully.
Warning = 7
A task completed, but something needs attention.
Error = 8
A task failed, or an action was rejected — an invalid drop target, a form that will not submit.
KeyPress = 9
A key went down on an on-screen keyboard.
KeyRelease = 10
A key came up on an on-screen keyboard.
LongPress = 11
A long press crossed its threshold and is now committed. Fire this at the MOMENT the threshold is crossed, not when the finger lifts — the whole point is to tell the user they can let go.
ContextClick = 12
A secondary/context action was invoked — a right-click, a long-press menu opening.
TextHandleMove = 13
A text selection handle moved to a new character position.
GestureStart = 14
A continuous gesture began and is now tracking.
GestureEnd = 15
A continuous gesture ended.
Rise = 16
A quick upward sweep — something growing, expanding, being picked up.
Fall = 17
A quick downward sweep — something shrinking, collapsing, being dropped.
Spin = 18
A spinning, bidirectional flutter — momentum, a wheel being flicked.
Implementations§
Source§impl HapticPattern
impl HapticPattern
Sourcepub const fn fallback(self) -> Option<HapticPattern>
pub const fn fallback(self) -> Option<HapticPattern>
The next-simplest pattern to try when a backend cannot render this one.
Backends walk this chain rather than silently dropping the request, so
a caller asking for Spin on a device whose actuator predates the
primitive still feels something. Every chain terminates at
Selection, which every haptic device on every platform can render;
Selection itself returns None, which is the signal to give up.
This exists because the degradation is a property of the PATTERN, not of the backend — otherwise all six backends would each invent their own (differing) fallback and the same call would feel unrelated across platforms.
Sourcepub fn resolve(
self,
supported: impl Fn(HapticPattern) -> bool,
) -> Option<HapticPattern>
pub fn resolve( self, supported: impl Fn(HapticPattern) -> bool, ) -> Option<HapticPattern>
Walk fallback until supported accepts a pattern.
Backends call this instead of matching on the pattern twice. Returns
None if nothing in the chain is supported, which means the request
should be dropped.
Trait Implementations§
Source§impl Clone for HapticPattern
impl Clone for HapticPattern
Source§fn clone(&self) -> HapticPattern
fn clone(&self) -> HapticPattern
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more