Skip to main content

Crate phoenixcord_sdk

Crate phoenixcord_sdk 

Source
Expand description

Rust bindings for the PhoenixCord plugin API.

Implement Plugin and export it with plugin!. Build the crate as a cdylib for the wasm32-wasip2 target to get a component PhoenixCord can load.

ⓘ
use phoenixcord_sdk::types::{Hook, OutgoingMessage, PluginInfo, SendDecision};
use phoenixcord_sdk::Plugin;

#[derive(Default)]
struct Shout;

impl Plugin for Shout {
    fn info() -> PluginInfo {
        PluginInfo {
            hooks: vec![Hook::MessagePreSend],
            ..PluginInfo::new("Shout", "Sends every message in capitals", &["you"])
        }
    }

    fn pre_send(&mut self, message: OutgoingMessage) -> SendDecision {
        SendDecision::Replace(message.content.to_uppercase())
    }
}

phoenixcord_sdk::plugin!(Shout);

Re-exports§

pub use exports::phoenixcord::sdk::plugin::Guest;
pub use phoenixcord::sdk::actions;
pub use phoenixcord::sdk::client;
pub use phoenixcord::sdk::host;
pub use phoenixcord::sdk::types;

Modules§

exports
phoenixcord

Macros§

export
Generates #[unsafe(no_mangle)] functions to export the specified type as the root implementation of all generated traits.
plugin
Exports a Plugin implementation as the component’s plugin interface. Use it once per plugin crate.

Structs§

View
A UI tree that can nest freely.

Traits§

Plugin
A PhoenixCord plugin.