Skip to main content

lockstep_contract

Function lockstep_contract 

Source
pub fn lockstep_contract(name: &str, version: &str) -> PluginContract
Expand description

Builds the compatibility contract a first-party plugin declares from Plugin::contract (issue #1601).

First-party plugins ship in lockstep with autumn-web, so the declared range is this crate’s own minor series — the two versions are the same number by construction. Below 1.0 a minor bump is breaking (see STABILITY.md), which is exactly what the MAJOR.MINOR requirement says.

Pass env!("CARGO_PKG_NAME") / env!("CARGO_PKG_VERSION") so both fields describe the calling crate, not this one:

use autumn_web::app::AppBuilder;
use autumn_web::plugin::Plugin;
use autumn_web::plugin_contract::{PluginContract, lockstep_contract};

struct MyFirstPartyPlugin;

impl Plugin for MyFirstPartyPlugin {
    fn contract(&self) -> Option<PluginContract> {
        Some(lockstep_contract(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")))
    }

    fn build(self, app: AppBuilder) -> AppBuilder {
        app
    }
}

§This is for lockstep crates only

Same restriction as lockstep_range: a plugin that versions independently of autumn-web must declare its own literal range instead (see that function’s docs for why).