Skip to main content

KitConfig

Struct KitConfig 

Source
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: String

Application id. Determines the data dir ~/.{id}, and is part of the default HTTP User-Agent.

§manifest_name: String

File 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: String

Plugin 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: String

Prefix 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: String

Name of the host’s contract crate, such as "bmux-plugin". The generated wrapper project depends on it.

§contract_version: String

Version requirement for the contract crate, such as "0.1".

§wrapper_edition: String

Edition used by the generated wrapper project.

§wrapper_body: String

Template 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: Duration

Timeout for waiting on the install lock.

§prefer_prebuilt: bool

Whether 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: String

crates.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

Source

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:

FieldValue
manifest_namemyapp-plugin.toml
crate_prefixmyapp-plugin-
lib_stem_prefixmyapp_plugin_
entry_symbolmyapp_plugin_entry_v1
contract_cratemyapp-plugin

wrapper_body (its paths come from the host’s contract crate) and contract_version still have to be filled in by hand.

entry_symbol does not need a trailing NUL — libloading adds it.

Source

pub fn with_data_dir(self, dir: impl Into<PathBuf>) -> Self

Overrides the data dir.

Source

pub fn with_lock_timeout(self, t: Duration) -> Self

Overrides the lock wait time.

Source

pub fn effective_target(&self) -> &str

Target triple of this build. The configured override wins.

Source

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.

Source

pub fn lib_stem(&self, crate_name: &str) -> String

Derives the cdylib file name stem (without the lib prefix and extension) from a crate name.

bmux-plugin-cargo → bmux_plugin_cargo

Source

pub fn paths(&self) -> KitResult<KitPaths>

Resolves the various paths. Creates directories as needed.

Trait Implementations§

Source§

impl Clone for KitConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KitConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.