pub trait Plugin: Default + 'static {
Show 23 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 http(&mut self, request: HttpRequest) -> Option<HttpResponse> { ... }
fn chat(&mut self, attempt: ChatAttempt) -> Action { ... }
fn kick(&mut self, ctx: Context) -> Action { ... }
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 job_done(&mut self, handle: u64, outcome: Result<Vec<u8>, String>) { ... }
fn work_init(&mut self, config: &str) -> Result<(), String> { ... }
fn work(&mut self, payload: Vec<u8>) -> Result<Vec<u8>, String> { ... }
}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§
Sourcefn init(&mut self, config: &str) -> Result<Registration, String>
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.
Sourcefn reload(&mut self, config: &str) -> Result<(), String>
fn reload(&mut self, config: &str) -> Result<(), String>
The configuration changed and the manifest sets hot_reload = true.
Sourcefn route(&mut self, connection: Connection) -> RouteDecision
fn route(&mut self, connection: Connection) -> RouteDecision
A TCP connection was accepted, before any bytes are read.
Sourcefn initial_server(&mut self, ctx: Context) -> Action
fn initial_server(&mut self, ctx: Context) -> Action
Choose the first backend. Accepts continue, deny and server.
Sourcefn before_transfer(&mut self, ctx: Context) -> Action
fn before_transfer(&mut self, ctx: Context) -> Action
A transfer is about to happen. Accepts continue and deny.
Sourcefn command(&mut self, ctx: Context) -> Action
fn command(&mut self, ctx: Context) -> Action
A registered command ran; ctx.command is its name, also when an
alias was typed, and ctx.args the text after it. Accepts
continue, message, server, queue and leave-queue.
For a command registered with CommandSpec::console, ctx.console
tells that the operator console runs it: there is no player then
(ctx.uuid is empty and ctx.name is CONSOLE), and a message
answer is shown to the operator.
Sourcefn suggest(&mut self, ctx: Context) -> Vec<Suggestion>
fn suggest(&mut self, ctx: Context) -> Vec<Suggestion>
Complete an argument of a command registered with
SuggestKind::Dynamic.
Sourcefn status(&mut self, ping: Ping) -> Option<StatusOverride>
fn status(&mut self, ping: Ping) -> Option<StatusOverride>
A server-list ping; return the fields to replace.
Sourcefn http(&mut self, request: HttpRequest) -> Option<HttpResponse>
fn http(&mut self, request: HttpRequest) -> Option<HttpResponse>
An authenticated request to /ext or /ext/* on the web server.
Sourcefn chat(&mut self, attempt: ChatAttempt) -> Action
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. Accepts continue,
which lets it through unchanged, and deny, which drops it and shows
the player the text.
Delivered only when Registration::hooks lists Hook::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.
Sourcefn kick(&mut self, ctx: Context) -> Action
fn kick(&mut self, ctx: Context) -> Action
A backend kicked a player in play: ctx.server is the backend and
ctx.reason its reason without formatting. continue leaves it to
network.on_kick, deny disconnects the player with the text and
server moves them there.
Delivered only when Registration::hooks lists Hook::Kick.
Sourcefn after_transfer(&mut self, ctx: Context)
fn after_transfer(&mut self, ctx: Context)
A transfer finished (see ctx.success).
Sourcefn disconnect(&mut self, ctx: Context)
fn disconnect(&mut self, ctx: Context)
A session closed (see ctx.reason).
Sourcefn message(&mut self, message: BusMessage)
fn message(&mut self, message: BusMessage)
A message arrived on a subscription made with bus::subscribe.
Sourcefn timer(&mut self, handle: u64)
fn timer(&mut self, handle: u64)
A timer made with timers::every or timers::after fired.
Sourcefn dialog(&mut self, response: DialogResponse)
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.
Sourcefn job_done(&mut self, handle: u64, outcome: Result<Vec<u8>, String>)
fn job_done(&mut self, handle: u64, outcome: Result<Vec<u8>, String>)
A job started with background::run finished: handle is the one
run returned and outcome what Plugin::work returned on the
worker, or why the job failed. Delivered without being listed in
Registration::hooks.
Sourcefn work_init(&mut self, config: &str) -> Result<(), String>
fn work_init(&mut self, config: &str) -> Result<(), String>
Background workers only: called once per worker before its first job, with the plugin’s configuration as JSON.
A worker is a separate instance of the component. self is a fresh
Default value that only work_init and Plugin::work ever
see; Plugin::init is never called on it.
Sourcefn work(&mut self, payload: Vec<u8>) -> Result<Vec<u8>, String>
fn work(&mut self, payload: Vec<u8>) -> Result<Vec<u8>, String>
Background workers only: one job queued with background::run.
It may block; the plugin’s hooks keep running meanwhile. The result
reaches Plugin::job_done on the plugin’s main instance.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".