Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Default + 'static {
Show 21 methods // Provided methods fn init(&mut self, config: &str) -> Result<Registration, String> { ... } fn reload(&mut self, config: &str) -> Result<(), String> { ... } fn shutdown(&mut self, reason: &str) { ... } fn route(&mut self, connection: Connection) -> RouteDecision { ... } fn login(&mut self, ctx: Context) -> Action { ... } fn initial_server(&mut self, ctx: Context) -> Action { ... } fn before_transfer(&mut self, ctx: Context) -> Action { ... } fn command(&mut self, ctx: Context) -> Action { ... } fn suggest(&mut self, ctx: Context) -> Vec<Suggestion> { ... } fn status(&mut self, ping: Ping) -> Option<StatusOverride> { ... } fn suggest_rich(&mut self, ctx: Context) -> Vec<RichSuggestion> { ... } fn status_rich(&mut self, ping: Ping) -> Option<RichStatusOverride> { ... } fn http(&mut self, request: HttpRequest) -> Option<HttpResponse> { ... } fn join(&mut self, ctx: Context) { ... } fn after_transfer(&mut self, ctx: Context) { ... } fn disconnect(&mut self, ctx: Context) { ... } fn message(&mut self, message: BusMessage) { ... } fn timer(&mut self, handle: u64) { ... } fn event(&mut self, event: RiftEvent) { ... } fn dialog(&mut self, response: DialogResponse) { ... } fn chat(&mut self, attempt: ChatAttempt) -> Action { ... }
}
Expand description

A Rift plugin. Implement the hooks you need and pass the type to export!.

The instance is created with Default before Plugin::init; see the crate documentation for how state is kept.

Provided Methods§

Source

fn init(&mut self, config: &str) -> Result<Registration, String>

Called once per instance with the plugin’s configuration as JSON ({} without one). Create timers and bus subscriptions here.

Source

fn reload(&mut self, config: &str) -> Result<(), String>

The configuration changed and the manifest sets hot_reload = true.

Source

fn shutdown(&mut self, reason: &str)

The instance is about to be dropped.

Source

fn route(&mut self, connection: Connection) -> RouteDecision

A TCP connection was accepted, before any bytes are read.

Source

fn login(&mut self, ctx: Context) -> Action

A player authenticated. Accepts continue and deny.

Source

fn initial_server(&mut self, ctx: Context) -> Action

Choose the first backend. Accepts continue, deny and server.

Source

fn before_transfer(&mut self, ctx: Context) -> Action

A transfer is about to happen. Accepts continue and deny.

Source

fn command(&mut self, ctx: Context) -> Action

A registered command ran. Accepts continue, message, server, queue and leave-queue.

Source

fn suggest(&mut self, ctx: Context) -> Vec<Suggestion>

Complete an argument of a command registered with SuggestKind::Dynamic.

Source

fn status(&mut self, ping: Ping) -> Option<StatusOverride>

A server-list ping; return the fields to replace.

Source

fn suggest_rich(&mut self, ctx: Context) -> Vec<RichSuggestion>

Plugin::suggest with JSON text tooltips (since 0.1.4). The default answers with Plugin::suggest.

Source

fn status_rich(&mut self, ping: Ping) -> Option<RichStatusOverride>

Plugin::status with JSON text for the version and the player sample (since 0.1.4). The default answers with Plugin::status.

Source

fn http(&mut self, request: HttpRequest) -> Option<HttpResponse>

An authenticated request to /api/script/*.

Source

fn join(&mut self, ctx: Context)

A player joined.

Source

fn after_transfer(&mut self, ctx: Context)

A transfer finished (see ctx.success).

Source

fn disconnect(&mut self, ctx: Context)

A session closed (see ctx.reason).

Source

fn message(&mut self, message: BusMessage)

A message arrived on a subscription made with bus::subscribe.

Source

fn timer(&mut self, handle: u64)

A timer made with timers::every or timers::after fired.

Source

fn event(&mut self, event: RiftEvent)

A Rift event (rift.events.*).

Source

fn dialog(&mut self, response: DialogResponse)

A player clicked a plugin action of a dialog this plugin showed with players::show_dialog. Delivered without being listed in Registration::hooks.

Source

fn chat(&mut self, attempt: ChatAttempt) -> Action

A player sent a chat message, or a command that neither Rift nor a plugin owns, and the backend has not seen it yet (since 0.1.5). Accepts continue, which lets it through unchanged, and deny (Action::Deny, Action::deny_json), which drops it and shows the player the text.

Called only for a plugin exported with export!(Type, chat); see the crate documentation for what that requires of the proxy. For a command, attempt.ctx.command is the root name and attempt.ctx.args the rest.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§