Skip to main content

zlink_core/introspect/
reply_error.rs

1use crate::idl::Error;
2
3/// Trait providing description of a interface method reply error type.
4pub trait ReplyError {
5    /// The list of possible errors variants.
6    const VARIANTS: &'static [&'static Error<'static>];
7}
8
9#[cfg(test)]
10mod tests {
11    use super::*;
12
13    #[test]
14    fn reply_errors() {
15        // Test with a type that implements ReplyErrors.
16        struct MyType;
17
18        const MY_ERROR: Error<'static> = Error::new("MyError", &[], &[]);
19
20        impl ReplyError for MyType {
21            const VARIANTS: &'static [&'static Error<'static>] = &[&MY_ERROR];
22        }
23
24        assert_eq!(MyType::VARIANTS.len(), 1);
25        assert_eq!(MyType::VARIANTS[0].name(), "MyError");
26    }
27}