Skip to main content

Crate day_part_haptics

Crate day_part_haptics 

Source
Expand description

day-part-haptics — a HEADLESS cross-platform haptic-feedback API. No UI; any Rust code can depend on this crate and call play to fire a haptic through the platform’s NATIVE API.

use day_part_haptics::Haptic;
if day_part_haptics::is_supported() {
    day_part_haptics::play(Haptic::Success);
}

Platform selection is purely #[cfg(target_os)] (a haptic engine is an OS concern, not a widget-toolkit one): iOS uses UIKit’s feedback generators, macOS NSHapticFeedbackManager, and Android Vibrator/VibrationEffect (via a Java shim staged by day build). Every other target — Windows, desktop Linux (GTK/Qt), HarmonyOS — has no haptic engine wired here, so play is a no-op and is_supported returns false.

play is fire-and-forget and best-effort: it never blocks, never returns an error, and never panics. On hardware without a Taptic engine (an iOS Simulator, a Mac without a Force Touch trackpad, an Android device whose Vibrator.hasVibrator() is false) the call is silently ignored.

Enums§

Haptic
A haptic-feedback style, modeled on iOS’s three feedback-generator families so the same call maps to a sensible native pattern everywhere.

Functions§

is_supported
Whether this platform has a haptic engine wired up. true on iOS/macOS/Android (even on a Simulator or a device that happens to lack the hardware — this reports API availability, not a live hardware probe), false on every other target, where play is a no-op.
play
Play a haptic through the platform’s native API. Fire-and-forget: no return value, never panics, and a no-op on platforms/hardware without a haptic engine (see is_supported).
Day API ↩ Guides· daybrite.dev