Skip to main content

tauri_plugin_haptics/
models.rs

1// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
2// SPDX-License-Identifier: Apache-2.0
3// SPDX-License-Identifier: MIT
4
5use serde::{Deserialize, Serialize};
6/*
7#[derive(Debug, Clone, Default, Serialize, Deserialize)]
8#[cfg_attr(feature = "specta", derive(specta::Type))]
9#[serde(rename_all = "camelCase")]
10pub struct HapticsOptions {
11    // TODO: support array to match web api
12    pub duration: u32,
13}
14 */
15
16/// The style of an impact-feedback haptic.
17///
18/// On iOS this maps directly to a `UIImpactFeedbackGenerator.FeedbackStyle` case. On Android,
19/// which has no equivalent system API, each style instead plays a distinct vibration waveform of
20/// increasing intensity. Has no effect on desktop platforms. Defaults to `Medium`.
21#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
22#[cfg_attr(feature = "specta", derive(specta::Type))]
23#[serde(rename_all = "camelCase")]
24pub enum ImpactFeedbackStyle {
25    /// A collision between small, light user interface elements.
26    Light,
27    /// A collision between moderately sized user interface elements.
28    #[default]
29    Medium,
30    /// A collision between large, heavy user interface elements.
31    Heavy,
32    /// A soft, muted impact between user interface elements.
33    Soft,
34    /// A sharp, rigid impact between user interface elements.
35    Rigid,
36}
37
38/// The type of notification feedback, indicating the outcome of a task or action.
39///
40/// On iOS this maps directly to a `UINotificationFeedbackGenerator.FeedbackType` case. On
41/// Android, which has no equivalent system API, each type instead plays a distinct vibration
42/// waveform. Has no effect on desktop platforms. Defaults to `Success`.
43#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
44#[cfg_attr(feature = "specta", derive(specta::Type))]
45#[serde(rename_all = "camelCase")]
46pub enum NotificationFeedbackType {
47    /// A task or action has completed successfully.
48    #[default]
49    Success,
50    /// A task or action has produced a warning.
51    Warning,
52    /// A task or action has failed.
53    Error,
54}