76 lines
1.3 KiB
C
76 lines
1.3 KiB
C
# 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
|
|
```
|