extern crate fidius_core as fidius;
use fidius_macro::plugin_interface;
#[plugin_interface(version = 1, buffer = PluginAllocated)]
pub trait TypedPipe: Send + Sync {
fn process(&self, data: Vec<u8>) -> Vec<u8>;
}
#[plugin_interface(version = 1, buffer = PluginAllocated)]
pub trait RawPipe: Send + Sync {
#[wire(raw)]
fn process(&self, data: Vec<u8>) -> Vec<u8>;
}
#[test]
fn raw_marker_changes_interface_hash() {
let typed = __fidius_TypedPipe::TypedPipe_INTERFACE_HASH;
let raw = __fidius_RawPipe::RawPipe_INTERFACE_HASH;
assert_ne!(
typed, raw,
"raw and typed methods with identical Rust signatures must hash differently",
);
}
#[plugin_interface(version = 1, buffer = PluginAllocated)]
pub trait Mixed: Send + Sync {
#[wire(raw)]
fn bulk(&self, payload: Vec<u8>) -> Vec<u8>;
fn ping(&self) -> String;
#[optional(since = 2)]
#[wire(raw)]
fn bulk_v2(&self, payload: Vec<u8>) -> Vec<u8>;
}
#[test]
fn mixed_interface_companion_module_compiles() {
let _ = __fidius_Mixed::Mixed_INTERFACE_HASH;
let _ = __fidius_Mixed::Mixed_INTERFACE_VERSION;
let _ = __fidius_Mixed::METHOD_BULK;
let _ = __fidius_Mixed::METHOD_PING;
let _ = __fidius_Mixed::METHOD_BULK_V2;
let _ = __fidius_Mixed::Mixed_CAP_BULK_V2;
}
#[plugin_interface(version = 1, buffer = PluginAllocated)]
pub trait FallibleBytePipe: Send + Sync {
#[wire(raw)]
fn maybe(&self, data: Vec<u8>) -> Result<Vec<u8>, fidius::PluginError>;
}
#[test]
fn raw_method_with_result_return_compiles() {
let _ = __fidius_FallibleBytePipe::FallibleBytePipe_INTERFACE_HASH;
let _ = __fidius_FallibleBytePipe::METHOD_MAYBE;
}