bext-plugin-api 0.2.0

Plugin trait definitions and shared types for bext — the public ABI for plugin authors
Documentation
  • Coverage
  • 79.21%
    400 out of 505 items documented0 out of 199 items with examples
  • Size
  • Source code size: 151.85 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 26.7 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 59s Average build duration of successful builds.
  • all releases: 59s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • bext-stack/bext
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • benfavre

bext-plugin-api

Public ABI for bext plugin authors. This is the single crate you need to depend on if you want to write a plugin for bext.

[dependencies]
bext-plugin-api = "0.2"

What this crate is

bext-plugin-api defines the trait hierarchy and shared types that every bext plugin implements. It has near-zero dependencies (just serde) so that plugin authors can pull it into any Rust project without dragging in the rest of the bext runtime.

The crate is the stable contract between the bext core engine and third-party extensions. The rest of the bext codebase will break you on a major version bump; this crate will not.

Plugin kinds

The crate exposes trait definitions for the following plugin kinds. Each plugin kind has its own module and its own lifecycle hooks.

Module Trait Purpose
auth AuthPlugin JWT, cookie, or custom authentication
session SessionStore Session persistence (cookie, redis, custom)
mailer Mailer Transactional email sending (SMTP, SES, etc.)
scheduled ScheduledTask Cron-like scheduled background jobs
tracer Tracer Structured tracing (stdout, OTLP, custom)
(core) Plugin Generic request/response middleware

Example

use bext_plugin_api::{Plugin, Request, Response};

pub struct HelloPlugin;

impl Plugin for HelloPlugin {
    fn on_request(&self, req: &Request) -> Option<Response> {
        if req.path() == "/hello" {
            Some(Response::text(200, "Hello from a bext plugin"))
        } else {
            None
        }
    }
}

Plugins are loaded by the bext runtime through one of the host crates:

Reference implementations

The bext-impls sub-workspace ships reference plugins you can use as starting points — JWT auth, cookie/Redis sessions, SMTP/SES mailers, stdout/OTLP tracers, and a cron scheduler. Each is a complete working plugin against this ABI, under ~500 lines of Rust.

License

MIT. This crate must stay MIT so plugin authors can link it freely into projects of any license.

Stability

Pre-1.0, the ABI is evolving. Minor version bumps (0.2 → 0.3) may include breaking changes to trait signatures. Patch bumps (0.2.0 → 0.2.1) are additive only. Once the crate reaches 1.0 it will follow strict semver for the public ABI.