pub struct BridgeContext { /* private fields */ }Expand description
Context for rendering the runtime bridge template.
The forbidden-char/forbidden-env-name fields are rendered directly from
mcp_execution_core’s canonical lists so the generated bridge’s copies structurally
cannot drift from the Rust source of truth — see BridgeContext::default, the only way
to construct one, which populates them from mcp_execution_core::forbidden_chars/
forbidden_env_names/forbidden_env_prefix rather than leaving them empty. This
deliberately does not derive Default: an empty forbidden_chars would render a bridge
whose validateCommandString accepts every shell metacharacter (fail-open on exactly the
check this exists to enforce), so Default is hand-written to make “always populated” a
property of the type rather than a convention callers must remember to uphold.
The three fields are private with read-only accessors for the same reason: pub fields
would let BridgeContext { forbidden_chars: vec![], .. } bypass the invariant entirely and
still compile, silently reintroducing the fail-open state Default exists to prevent.
Deserialize is intentionally not derived — nothing in this codebase deserializes a
BridgeContext from external input, and doing so would need to re-validate non-emptiness
rather than trust the wire data.
§Examples
use mcp_execution_codegen::progressive::BridgeContext;
let context = BridgeContext::default();
assert!(!context.forbidden_chars().is_empty());
assert!(context.forbidden_chars().contains(&";".to_string()));
assert!(!context.forbidden_env_prefix().is_empty());Implementations§
Source§impl BridgeContext
impl BridgeContext
Sourcepub fn forbidden_chars(&self) -> &[String]
pub fn forbidden_chars(&self) -> &[String]
Shell metacharacters forbidden in a command or argument string, each pre-escaped for safe embedding inside a single-quoted TypeScript string literal. Never empty.
§Examples
use mcp_execution_codegen::progressive::BridgeContext;
assert!(!BridgeContext::default().forbidden_chars().is_empty());Sourcepub fn forbidden_env_names(&self) -> &[String]
pub fn forbidden_env_names(&self) -> &[String]
Forbidden environment variable names (exact match). Never empty.
§Examples
use mcp_execution_codegen::progressive::BridgeContext;
assert!(!BridgeContext::default().forbidden_env_names().is_empty());Sourcepub fn forbidden_env_prefix(&self) -> &str
pub fn forbidden_env_prefix(&self) -> &str
Environment-variable-name prefix rejected regardless of exact match (e.g. DYLD_).
Never empty.
§Examples
use mcp_execution_codegen::progressive::BridgeContext;
assert!(!BridgeContext::default().forbidden_env_prefix().is_empty());Trait Implementations§
Source§impl Clone for BridgeContext
impl Clone for BridgeContext
Source§fn clone(&self) -> BridgeContext
fn clone(&self) -> BridgeContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BridgeContext
impl Debug for BridgeContext
Source§impl Default for BridgeContext
impl Default for BridgeContext
Source§fn default() -> Self
fn default() -> Self
Populates the forbidden-char/forbidden-env-name fields directly from
mcp_execution_core’s canonical lists, so BridgeContext::default() can never render
a bridge with an empty (fail-open) FORBIDDEN_CHARS. Each character is passed through
sanitize_ts_string_literal (this crate’s TS-string-literal escaper) so it renders as
a syntactically valid single-quoted TypeScript string literal regardless of what the
Rust list contains.