macro_rules! enum_labeled {
(
$enum_vis:vis $enum_identifier:ident,
$enum_discriminant_type:ty,
$enum_label:expr,
[
$(
[
$variant_discriminant:expr;
$variant_identifier:ident;
$variant_type:ty;
$variant_const_identifier:ident;
$variant_acronym:expr;
$variant_description:expr
]
),* $(,)?
]
) => { ... };
}Expand description
A macro that defines an error type and error handling for syscalls.
This macro generates:
- An Error enum with the specified variants and their associated discriminant values
- ErrorTrait implementation for the Error type with proper discriminant mapping
- An discriminant module with standard Linux error constants
- Into
implementation for the Error type - A handle_result function that maps arch errors to syscall errors
§Arguments
$enum_identifier- The name of the error enum (usually Error)$variant- The variant name in the crate::result::Error enum (e.g., Open, Read, Write)$enum_label- String slice with the syscall name- A list of error variants with their descriptions, discriminant values and Linux standard constant names [VariantName, discriminant_value, “description”, “LINUX_CONSTANT”]
§Example
$enum_identifier:ident,
$variant:ty,
$enum_label:expr,
[
$(
[
$variant_discriminant:expr;
$variant_identifier:ident;
$variant_const_identifier:ident;
$variant_acronym:expr;
$variant_description:expr
]
),* $(,)?
]