Skip to main content

WorkbookBuilderExt

Trait WorkbookBuilderExt 

Source
pub trait WorkbookBuilderExt: Sized {
    // Required methods
    fn with_workbook_bundle(self, source: &dyn BundleSource) -> Self;
    fn try_with_workbook_bundle(self, source: &dyn BundleSource) -> Result<Self>;
}
Expand description

Composable builder extension wiring a verified workbook bundle into a pmcp::ServerBuilder in ONE call.

WorkbookBuilderExt::with_workbook_bundle / WorkbookBuilderExt::try_with_workbook_bundle load + integrity-verify a BundleSource at boot (fail-closed — a tampered bundle aborts the boot, WBSV-08), then register all FIVE served tools (calculate, explain, get_manifest, diff_version, render_workbook) plus the workbook:// render resource. Mirrors crate::builder_ext::ServerBuilderExt’s panicking-convenience + fallible-companion pair (review R7): production servers should prefer the try_ form so a tampered/malformed bundle surfaces as a Result, not a crash.

This is THE consumer-side contract: Shape A/B servers depend ONLY on pmcp-server-toolkit and never name pmcp-workbook-runtime (the loader, source impls, and error types are re-exported at this module / the crate root, D-11).

Required Methods§

Source

fn with_workbook_bundle(self, source: &dyn BundleSource) -> Self

Load + verify source and register all five workbook tools + the workbook:// resource. Panicking convenience wrapping WorkbookBuilderExt::try_with_workbook_bundle.

§Panics

Panics with "with_workbook_bundle: ..." if the bundle fails to load or its recomputed integrity hashes do not match its lock (a tampered / malformed bundle, BundleLoadError). Prefer WorkbookBuilderExt::try_with_workbook_bundle for production servers where a bad bundle must surface as a Result (WBSV-08).

§Example
use pmcp::Server;
use pmcp_server_toolkit::workbook::{LocalDirSource, WorkbookBuilderExt};

let source = LocalDirSource::new("bundles/tax-calc@1.1.0");
let _builder = Server::builder()
    .name("workbook-tax-calc")
    .version("1.1.0")
    .with_workbook_bundle(&source);
Source

fn try_with_workbook_bundle(self, source: &dyn BundleSource) -> Result<Self>

Fallible companion to WorkbookBuilderExt::with_workbook_bundle (review R7) — the boot LOAD is fail-closed (WBSV-08): a tampered or malformed bundle returns Err BEFORE any tool is registered, so the server never boots on an unverified bundle.

§Errors

Returns crate::ToolkitError (wrapping a BundleLoadError) if the bundle fails to load — typically a source read error, a JSON parse failure, or an integrity-hash mismatch (a swapped / tampered artifact).

§Example
use pmcp::Server;
use pmcp_server_toolkit::workbook::{LocalDirSource, WorkbookBuilderExt};

let source = LocalDirSource::new("bundles/tax-calc@1.1.0");
let _builder = Server::builder()
    .name("workbook-tax-calc")
    .version("1.1.0")
    .try_with_workbook_bundle(&source)?;

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl WorkbookBuilderExt for ServerBuilder

Source§

fn with_workbook_bundle(self, source: &dyn BundleSource) -> Self

Source§

fn try_with_workbook_bundle(self, source: &dyn BundleSource) -> Result<Self>

Implementors§