pub enum Error<'a> {
Show 20 variants
OutOfMemory,
QueueSendTimeout,
QueueReceiveTimeout,
MutexTimeout,
MutexLockFailed,
Timeout,
QueueFull,
StringConversionError,
TaskNotFound,
InvalidQueueSize,
NullPtr,
NotFound,
OutOfIndex,
InvalidType,
Empty,
WriteError(&'a str),
ReadError(&'a str),
ReturnWithCode(i32),
Unhandled(&'a str),
UnhandledOwned(String),
}Expand description
Error types for OSAL-RS operations.
Represents all possible error conditions that can occur when using the OSAL-RS library.
§Lifetime Parameter
The error type is generic over lifetime 'a to allow flexible error messages.
Most of the time, you can use the default Result<T> type alias which uses
Error<'static>. For custom lifetimes in error messages, use
core::result::Result<T, Error<'a>> explicitly.
§Examples
§Basic usage with static errors
use osal_rs::os::{Queue, QueueFn};
use osal_rs::utils::Error;
match Queue::new(10, 32) {
Ok(queue) => { /* use queue */ },
Err(Error::OutOfMemory) => println!("Failed to allocate queue"),
Err(e) => println!("Other error: {:?}", e),
}§Using borrowed error messages
use osal_rs::utils::Error;
fn validate_input(input: &str) -> core::result::Result<(), Error> {
if input.is_empty() {
// Use static lifetime for compile-time strings
Err(Error::Unhandled("Input cannot be empty"))
} else {
Ok(())
}
}
// For dynamic error messages from borrowed data
fn process_data<'a>(data: &'a str) -> core::result::Result<(), Error<'a>> {
if !data.starts_with("valid:") {
// Error message borrows from 'data' lifetime
Err(Error::ReadError(data))
} else {
Ok(())
}
}Variants§
OutOfMemory
Insufficient memory to complete operation
QueueSendTimeout
Queue send operation timed out
QueueReceiveTimeout
Queue receive operation timed out
MutexTimeout
Mutex operation timed out
MutexLockFailed
Failed to acquire mutex lock
Timeout
Generic timeout error
QueueFull
Queue is full and cannot accept more items
StringConversionError
String conversion failed
TaskNotFound
Thread/task not found
InvalidQueueSize
Invalid queue size specified
NullPtr
Null pointer encountered
NotFound
Requested item not found
OutOfIndex
Index out of bounds
InvalidType
Invalid type for operation
Empty
No data available
WriteError(&'a str)
Write error occurred
ReadError(&'a str)
Read error occurred
ReturnWithCode(i32)
Return error with code
Unhandled(&'a str)
Unhandled error with description
UnhandledOwned(String)
Unhandled error with description owned