pub struct Config {Show 23 fields
pub modes: ModeWords,
pub capabilities: Capabilities,
pub addr: String,
pub bearer_tokens: Vec<String>,
pub log_level: Level,
pub timeout: Duration,
pub cert_file: String,
pub key_file: String,
pub cors_origins: Vec<String>,
pub lang: String,
pub translations: HashMap<String, HashMap<String, String>>,
pub channel_defaults: HashMap<String, String>,
pub help_before: String,
pub help_after: String,
pub name: String,
pub version: String,
pub format: String,
pub format_interactive: String,
pub format_piped: String,
pub format_from_flag: bool,
pub response_headers: Vec<(String, String)>,
pub no_server_headers: bool,
pub allow_unknown_query: bool,
}Expand description
Config 调整派发器。零值保持全部默认。
Fields§
§modes: ModeWords§capabilities: Capabilities§addr: Stringserve 与 mcp(http) 模式的默认监听地址(各模式自己的 –addr flag 优先)。
bearer_tokens: Vec<String>开启 serve REST 与 MCP http 传输的 Bearer 凭据校验,每个元素是 一个可接受的 token;空表示不校验。命令行写法:–xyz.bearer=tok1,tok2 (stdio 传输为本地进程,不受影响)。
log_level: Level库自身诊断的日志级别(logx 输出到 stderr)。零值(LevelUnset) 保持默认 Info。命令行:–xyz.log-level=debug|info|warn|error。
timeout: Durationserve 模式的每请求超时(TimeoutLayer);0 = 不设超时。 (标准头超时在 Rust 实现里未单独配置,见 README 与 Go 版差异节。)
cert_file: Stringcert_file/key_file 同时给定则 serve 以 TLS 监听 (–xyz.tls-cert/–xyz.tls-key)。
key_file: String§cors_origins: Vec<String>CORSOrigins 非空则开启 CORS:逐个 Origin 放行(“*” 表示任意来源), OPTIONS 预检在鉴权之前应答。命令行:–xyz.cors=origin1,origin2。
lang: String界面语言覆盖:“”=自动(–xyz.lang flag > 本字段 > LANG/LC_ALL 环境 检测 > 英文默认)。取值 “en” | “zh-CN”。
translations: HashMap<String, HashMap<String, String>>用户的多语言内容覆盖表:语言 → (消息键 → 文本)。键名见 lang 目录 (xyz-spec §15.8 的规范键表)。
channel_defaults: HashMap<String, String>serve/mcp 启动时注入的通道级默认参数(字段线上名 → 字符串值): 请求/调用未显式提供时自动补上,优先级高于全局 default 属性、低于 显式入参与接口默认。命令行:–default k=v(可重复/逗号分隔对)。
help_before: Stringhelp 总览的自定义文本块:前者原样插在总览开头(程序名/描述/版本/ 仓库地址等自己拼),后者插在结尾(命令表之后,即使命令表被隐藏也 打印)。空 = 不插入。
help_after: String§name: String应用名(spec §11.6/§12.6):X-App-Name 响应头与 MCP serverInfo.name。 空 = 二进制 basename。
version: String应用版本(spec §11.6/§12.6):X-App-Version 响应头与 serverInfo.version。空 = version::version()(默认 “dev”)。 与 xyz 库自身的版本(version::SDK_VERSION → X-XYZ-Version)无关。
format: String代码级全局默认格式(spec §10.7 第四层):“”|auto = 按 TTY 解析为 format_interactive / format_piped。命令行 –xyz.format(第二层, format_from_flag 置位)与逐命令 CliHints.format(第三层)优先。
format_interactive: Stringformat=auto 时交互式终端下的具体格式(默认 text)。
format_piped: Stringformat=auto 时非交互(管道/重定向/其他程序调用)下的具体格式 (默认 jsonl)。
format_from_flag: bool标记 format 来自命令行 –xyz.format(命令行层,高于逐命令 hint)。
response_headers: Vec<(String, String)>附加到每个 HTTP 响应的自定义静态头(键值原样写入;与自动 X-App-/X-XYZ- 头并存)。命令行:–xyz.header k=v(可重复)。
no_server_headers: bool关闭自动服务器上下文头(HTTP 的 X-App-/X-XYZ- 与 MCP 结果的 _meta.xyz):spec §11.6/§12.8 的单一开关。自定义头不受影响。 命令行:–xyz.no-server-headers。
allow_unknown_query: bool接受未知 query 参数(默认 false = 严格:400 invalid_input,消息列出
该路由允许的参数集;spec §11.2)。静默忽略会让拼错/已移除的参数看起来
生效。命令行:–xyz.allow-unknown-query。
Implementations§
Source§impl Config
impl Config
pub fn default_log_level(&self) -> Level
Sourcepub fn resolved_name(&self) -> String
pub fn resolved_name(&self) -> String
应用名:config 覆盖 > 二进制 basename(spec §11.6/§12.6)。
Sourcepub fn resolved_version(&self) -> String
pub fn resolved_version(&self) -> String
应用版本:config 覆盖 > 版本槽(默认 “dev”)。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more