Struct Build

Source
pub struct Build { /* private fields */ }
Expand description

Selects which artifacts to generate from an ExtensionSpec.

Each emit_* method enables an output; nothing is written until generate is called. Most build.rs files only need Build::new(ext).emit().generate().

Implementations§

Source§

impl Build

Source

pub fn new(extension: ExtensionSpec) -> Self

Creates a build for the given extension with no outputs enabled.

Source

pub fn emit(self) -> Self

Enables the default outputs: shorthand for emit_rust_guest followed by emit_abi_json.

Source

pub fn emit_defaults(self) -> Self

Alias for emit.

Source

pub fn emit_rust_guest(self) -> Self

Enables the Rust guest module, written to $OUT_DIR/ext_<name>.rs for consumption via include!.

Source

pub fn emit_abi_json(self) -> Self

Enables the ABI JSON contract, written to $OUT_DIR/<name>.abi.json. Use emit_abi_json_to when a stable, build-independent path is needed.

Source

pub fn emit_abi_json_to(self, path: impl Into<PathBuf>) -> Self

Additionally writes the ABI JSON to the given path (parent directories are created). Useful for checking the contract into the repo or feeding it to the CLI from a stable location.

Source

pub fn emit_java_host( self, out_dir: impl Into<PathBuf>, package: impl Into<String>, ) -> Self

Enables the Java (Chicory) host adapter, written as <Name>HostFunctions.java under out_dir in the given package’s directory layout. Note this writes directly into the given Java source tree from build.rs; running the boomslang-hostgen CLI against the emitted ABI JSON after the build is generally preferable.

Source

pub fn emit_rust_host(self, out_dir: impl Into<PathBuf>) -> Self

Enables the Rust (Wasmtime) host adapter, written as host_<name>.rs under out_dir. As with emit_java_host, generating hosts via the CLI after the build is generally preferable.

Source

pub fn generate(self) -> Result<(), Box<dyn Error>>

Validates the manifest and writes all enabled outputs.

Validation enforces the exact ABI version (currently 1), ASCII identifier rules for all names, the reserved __async_* function names, and that async functions return Type::String. Guest and default ABI JSON outputs require the OUT_DIR environment variable, which Cargo sets when running build.rs.

Auto Trait Implementations§

§

impl Freeze for Build

§

impl RefUnwindSafe for Build

§

impl Send for Build

§

impl Sync for Build

§

impl Unpin for Build

§

impl UnwindSafe for Build

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.