pub type TimerParam = Arc<dyn Any + Send + Sync>;Expand description
All OSAL trait definitions for advanced usage. Type-erased parameter for timer callbacks.
Allows passing arbitrary data to timer callback functions in a type-safe
manner. The parameter is wrapped in an Arc for safe sharing and can be
downcast to its original type.
§Thread Safety
The inner type must implement Any + Send + Sync since timer callbacks
execute in the timer service task context.
§Examples
use osal_rs::os::*;
use std::sync::Arc;
// Create a parameter
let param: TimerParam = Arc::new(7u32);
// In the timer callback, downcast to access it
let count = param.downcast_ref::<u32>().copied();
assert_eq!(count, Some(7));
// A downcast to the wrong type simply reports `None`.
assert!(param.downcast_ref::<i8>().is_none());Aliased Type§
pub struct TimerParam { /* private fields */ }