This repository has been archived on 2024-05-26. You can view files and clone it, but cannot push or open issues or pull requests.
trixy/tests/error_derive/expected.md

76 lines
1.3 KiB
Markdown
Raw Normal View History

2024-05-19 12:02:12 +00:00
# Host files
File path: `out/dir/api.rs`
```rust
// Host code
/* Rust API */
#[derive(trixy::__private::thiserror::Error)]
#[allow(non_camel_case_types)]
#[derive(Debug)]
pub enum ErrorOne {
#[error("I'm an error")]
Error,
#[error("I'm also an error'")]
ErrorB,
}
impl From<crate::ErrorOne_c> for ErrorOne {
fn from(value: crate::ErrorOne_c) -> Self {
match value {
crate::ErrorOne_c::Error => Self::Error,
crate::ErrorOne_c::ErrorB => Self::ErrorB,
}
}
}
#[derive(Debug)]
pub enum Commands {}
/* C API */
#[derive(trixy::__private::thiserror::Error)]
#[allow(non_camel_case_types)]
#[repr(C)]
#[derive(Debug)]
pub enum ErrorOne_c {
#[error("I'm an error")]
Error,
#[error("I'm also an error'")]
ErrorB,
}
impl From<crate::ErrorOne> for ErrorOne_c {
fn from(value: crate::ErrorOne) -> Self {
match value {
crate::ErrorOne::Error => Self::Error,
crate::ErrorOne::ErrorB => Self::ErrorB,
}
}
}
// vim: filetype=rust
```
# Auxiliary files
File path: `dist/interface.h`
```c
#if !defined TRIXY_MAIN_HEADER
#define TRIXY_MAIN_HEADER
#include "errno.h"
#include "string.h"
#include "vec.h"
/**
*/
enum ErrorOne
{
/**
*/
Error,
/**
*/
ErrorB,
};
#endif // if !defined TRIXY_MAIN_HEADER
// vim: filetype=c
```