Crates.io | mlpa |
lib.rs | mlpa |
version | 0.4.0 |
source | src |
created_at | 2024-05-30 21:03:36.498978 |
updated_at | 2024-08-05 19:59:39.223715 |
description | Plugin API for mailing-list |
homepage | |
repository | https://github.com/Ung-Data-Falun/mailing-list-plugin-api |
max_upload_size | |
id | 1257254 |
size | 38,133 |
mlpa is an API library for writing plugins for mailing-list
A plugin that says hello:
use std::ffi::CStr;
use std::os::raw::c_char;
use mlpa::Plugin;
#[no_mangle]
pub extern "C" fn get_plugin() -> Plugin {
use mlpa::Optional::Some;
Plugin {
message_handler: Some(message_handler),
}
}
extern "C" fn message_handler(message: *const c_char) {
let message = unsafe { CStr::from_ptr(message) };
let message = String::from_utf8_lossy(message.to_bytes()).to_string();
println!("Hello from plugin!");
println!("Message: {message}");
}
to build and use in mailing-list:
Cargo.toml
[lib]
crate-type = ["dylib"]
daemon.toml
plugins = [
"[your plugin]"
]