pub trait ToPriority {
// Required method
fn to_priority(&self) -> UBaseType;
}Expand description
Trait for converting types to thread priority values.
Allows flexible specification of thread priorities using different types (e.g., integers, enums) that can be converted to the underlying RTOS priority representation.
§Priority Ranges
Priority 0 is typically reserved for the idle task. Higher numbers indicate higher priority (preemptive scheduling).
§Examples
ⓘ
use osal_rs::traits::ToPriority;
// Implement for a custom priority enum
enum TaskPriority {
Low,
Medium,
High,
}
impl ToPriority for TaskPriority {
fn to_priority(&self) -> UBaseType {
match self {
TaskPriority::Low => 1,
TaskPriority::Medium => 5,
TaskPriority::High => 10,
}
}
}
let thread = Thread::new("worker", 1024, TaskPriority::High);