pub fn build_procedure_context<'a>(
host: &'a dyn ProcedureHost,
principal: Option<&'a Principal>,
) -> ProcedureContext<'a>Expand description
Build a ProcedureContext wiring host and an optional principal.
Replaces the duplicated “construct ProcedureContext::new(), chain
with_host, then conditionally chain with_principal” block. The
principal, when Some, is attached via the existing
ProcedureContext::with_principal builder; when None it is
simply omitted.
Writer attachment to the host happens at the call site because the
two host construction paths (from_components and
from_graph_ctx_with_request on QueryProcedureHost) differ in
shape; only the context-build was textually identical.
§Examples
use uni_plugin::host::context::build_procedure_context;
use uni_plugin::traits::connector::Principal;
use uni_plugin::traits::procedure::ProcedureHost;
let ctx = build_procedure_context(host, principal);
// pass `ctx` to `procedure.invoke(ctx, &args)`