mlpa

Crates.iomlpa
lib.rsmlpa
version0.4.0
sourcesrc
created_at2024-05-30 21:03:36.498978
updated_at2024-08-05 19:59:39.223715
descriptionPlugin API for mailing-list
homepage
repositoryhttps://github.com/Ung-Data-Falun/mailing-list-plugin-api
max_upload_size
id1257254
size38,133
vanten-s (vanten-s)

documentation

https://docs.rs/mlpa

README

mlpa

mlpa is an API library for writing plugins for mailing-list

Examples

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:

  1. Add to Cargo.toml
[lib]
crate-type = ["dylib"]
  1. Build your plugin
  2. Add to daemon.toml
plugins = [
    "[your plugin]"
]
Commit count: 14

cargo fmt