pub struct KitConfig {Show 15 fields
pub id: String,
pub manifest_name: String,
pub crate_prefix: String,
pub entry_symbol: Vec<u8>,
pub lib_stem_prefix: String,
pub contract_crate: String,
pub contract_version: String,
pub wrapper_edition: String,
pub wrapper_body: String,
pub data_dir: Option<PathBuf>,
pub lock_timeout: Duration,
pub prefer_prebuilt: bool,
pub target_triple: Option<String>,
pub registry: String,
pub local_overrides: BTreeMap<String, PathBuf>,
}Expand description
Every configurable item of a kit instance.
Fields§
§id: StringApplication id. Determines the data dir ~/.{id}, and is part of the default
HTTP User-Agent.
manifest_name: StringFile name of the plugin manifest, such as "bmux-plugin.toml".
The [plugin] and [lib] sections of the manifest are defined by this crate
(see crate::manifest). A host may append its own sections to the same file
(for example bmux’s [detect]); this crate ignores them.
crate_prefix: StringPlugin crate name prefix, such as "bmux-plugin-".
install("cargo") first expands to "bmux-plugin-cargo"; a name that already
carries the prefix is used as-is.
entry_symbol: Vec<u8>Entry symbol exported by the cdylib, such as b"bmux_plugin_entry_v1".
lib_stem_prefix: StringPrefix of the cdylib file name stem, such as "bmux_plugin_".
Concatenated with the crate name minus its prefix, then given the platform
extension, this yields the actual file name.
Example: bmux-plugin-cargo → bmux_plugin_ + cargo → libbmux_plugin_cargo.so.
contract_crate: StringName of the host’s contract crate, such as "bmux-plugin". The generated
wrapper project depends on it.
contract_version: StringFallback version requirement for the contract crate, such as "0.1".
Normally unused. The wrapper repeats whatever the plugin crate’s own manifest requires of the contract crate, which is the only way to guarantee both resolve to one version: cargo treats differently-versioned copies as distinct crates, each with its own traits, and will not merge them even when a single version satisfies both requirements. This value is only consulted when the plugin’s manifest declares no such dependency.
wrapper_edition: StringEdition used by the generated wrapper project.
wrapper_body: StringTemplate for the wrapper project’s src/lib.rs.
{crate_ident} is replaced with the plugin crate’s ident (- becomes _).
Example (bmux): "bmux_plugin::export!({crate_ident}::create);\n"
data_dir: Option<PathBuf>Data dir override. None = use ~/.{id}.
lock_timeout: DurationTimeout for waiting on the install lock.
prefer_prebuilt: boolWhether to try prebuilt artifacts first when installing.
target_triple: Option<String>Override for the target triple. None = use the triple injected at compile
time (see build.rs).
registry: Stringcrates.io index address. May point at a mirror.
local_overrides: BTreeMap<String, PathBuf>Local path overrides: crate name → local directory.
Written into the generated wrapper project as its [patch.crates-io]. For
development use: the wrapper lives under ~/.{id}/build/ and cannot see the
host project’s .cargo/config.toml, so local overrides must be passed
explicitly here. Leave empty in production.
Implementations§
Source§impl KitConfig
impl KitConfig
Sourcepub fn new(id: impl Into<String>) -> Self
pub fn new(id: impl Into<String>) -> Self
Starts a config from the minimum amount of information, with conservative defaults for the rest.
All defaults are derived from id and are mutually consistent — for example
id = "myapp" yields:
| Field | Value |
|---|---|
manifest_name | myapp-plugin.toml |
crate_prefix | myapp-plugin- |
lib_stem_prefix | myapp_plugin_ |
entry_symbol | myapp_plugin_entry_v1 |
contract_crate | myapp-plugin |
wrapper_body still has to be filled in by hand when the contract crate’s path differs
from the derivation above. contract_version does not: it is a fallback, and the wrapper
normally repeats whatever the plugin crate’s own manifest requires.
entry_symbol does not need a trailing NUL — libloading adds it.
Sourcepub fn with_data_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_data_dir(self, dir: impl Into<PathBuf>) -> Self
Overrides the data dir.
Sourcepub fn with_lock_timeout(self, t: Duration) -> Self
pub fn with_lock_timeout(self, t: Duration) -> Self
Overrides the lock wait time.
Sourcepub fn effective_target(&self) -> &str
pub fn effective_target(&self) -> &str
Target triple of this build. The configured override wins.
Sourcepub fn normalize_crate_name(&self, name: &str) -> String
pub fn normalize_crate_name(&self, name: &str) -> String
Normalizes the name passed to install() into a full crate name.
A name that already carries the prefix is returned as-is; otherwise the prefix is prepended.