polychat_plugin/plugin/
plugin_info.rs

1use crate::types::*;
2use super::api_version::APIVersion;
3use super::send_status::SendStatus;
4use super::message::Message;
5
6use std::option::Option;
7use std::ptr;
8
9use libc::c_char;
10
11#[repr(C)]
12pub struct PluginInfo {
13    pub supported_api: APIVersion,
14    pub name: *const c_char,
15
16    pub create_account: Option<extern fn() -> Account>,
17    pub destroy_account: Option<extern fn(acc: Account)>,
18    /// Instructs the plugin to post a message in the associated channel.
19    /// The lifetime of msg is only guaranteed during the function call.
20    /// To keep the message for longer (likely required), make a copy.
21    /// TODO: Add way to update future message status as it is done async.
22    pub post_message: Option<extern fn(msg: * const Message) -> SendStatus>,
23    pub print: Option<extern fn(acc: Account)>,
24}
25
26impl PluginInfo {
27    pub fn new() -> PluginInfo {
28        PluginInfo {
29            supported_api: APIVersion {
30                major: -1,
31                minor: 0,
32                patch: 0
33            },
34            create_account: None,
35            destroy_account: None,
36            post_message: None,
37            print: None,
38            name: ptr::null(),
39        }
40    }
41}