pub struct HapticPattern { /* private fields */ }Expand description
Re-export framework services (HTTP, URI, etc.) from the dedicated services crate. A vibration waveform: alternating durations with a target amplitude each.
This is Android’s VibrationEffect.createWaveform(long[], int[], int) in
framework terms. Index 0 is an off period by convention (its amplitude is
usually 0), then on, then off — but nothing enforces that, so an app is
free to shape a ramp out of consecutive non-zero amplitudes.
Amplitudes run 0 (off) to 255 (the device’s strongest). Devices without
amplitude control treat any non-zero amplitude as full strength; check
Haptics::has_amplitude_control before designing around subtle levels.
Implementations§
Source§impl HapticPattern
impl HapticPattern
Sourcepub const MAX_STEPS: usize = 512
pub const MAX_STEPS: usize = 512
The longest waveform the framework passes to a platform vibrator. Android’s own limit is device-defined and far lower in practice; this bound keeps a malformed pattern from reaching JNI at all.
Sourcepub fn new(
timings_ms: &[u32],
amplitudes: &[u8],
) -> Result<HapticPattern, HapticError>
pub fn new( timings_ms: &[u32], amplitudes: &[u8], ) -> Result<HapticPattern, HapticError>
Builds a one-shot waveform.
Fails when the two slices differ in length, when there are no steps, or when every timing is zero.
Sourcepub fn repeating(
timings_ms: &[u32],
amplitudes: &[u8],
repeat_index: usize,
) -> Result<HapticPattern, HapticError>
pub fn repeating( timings_ms: &[u32], amplitudes: &[u8], repeat_index: usize, ) -> Result<HapticPattern, HapticError>
Builds a waveform that loops back to repeat_index until
Haptics::cancel stops it.
Sourcepub fn timings_ms(&self) -> &[u32]
pub fn timings_ms(&self) -> &[u32]
The per-step durations in milliseconds.
Sourcepub fn amplitudes(&self) -> &[u8] ⓘ
pub fn amplitudes(&self) -> &[u8] ⓘ
The per-step amplitudes, 0 to 255.
Sourcepub fn total_duration_ms(&self) -> u32
pub fn total_duration_ms(&self) -> u32
One pass through the waveform, in milliseconds.
Sourcepub fn peak_amplitude(&self) -> u8
pub fn peak_amplitude(&self) -> u8
The strongest amplitude in the waveform, which is what a backend without waveform support falls back on.
Sourcepub fn closest_feedback(&self) -> HapticFeedback
pub fn closest_feedback(&self) -> HapticFeedback
The closest HapticFeedback constant for this pattern, derived from
its strength and length. Backends without waveform support use it.
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 moreSource§impl Debug for HapticPattern
impl Debug for HapticPattern
impl Eq for HapticPattern
Source§impl PartialEq for HapticPattern
impl PartialEq for HapticPattern
impl StructuralPartialEq for HapticPattern
Auto Trait Implementations§
impl Freeze for HapticPattern
impl RefUnwindSafe for HapticPattern
impl Send for HapticPattern
impl Sync for HapticPattern
impl Unpin for HapticPattern
impl UnsafeUnpin for HapticPattern
impl UnwindSafe for HapticPattern
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.