Skip to main content

RustBuilder

Struct RustBuilder 

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

Builder for Rust project compilation with smart defaults.

Discovers Cargo.toml by walking up from the starting path, parses project metadata, and provides methods to build and copy binaries to ~/hero/bin.

Implementations§

Source§

impl RustBuilder

Source

pub fn new() -> Self

Creates a new RustBuilder starting from the current directory.

Source

pub fn from_path<P: AsRef<Path>>(path: P) -> Self

Creates a new RustBuilder starting from the given path. The path can be a file or directory - will walk up to find Cargo.toml.

Source

pub fn release(self) -> Self

Sets the build profile to Release (production).

Source

pub fn debug(self) -> Self

Sets the build profile to Debug (development).

Source

pub fn profile(self, profile: BuildProfile) -> Self

Sets the build profile.

Source

pub fn bin(self, name: impl Into<String>) -> Self

Build a specific binary by name.

Source

pub fn lib(self) -> Self

Build the library.

Source

pub fn example(self, name: impl Into<String>) -> Self

Build a specific example.

Source

pub fn all_bins(self) -> Self

Build all binaries.

Source

pub fn feature(self, feature: impl Into<String>) -> Self

Enable a specific feature.

Source

pub fn features(self, features: Vec<String>) -> Self

Enable multiple features.

Source

pub fn all_features(self) -> Self

Enable all features.

Source

pub fn no_default_features(self) -> Self

Disable default features.

Source

pub fn copy_to_hero_bin(self) -> Self

Copy the built binary to ~/hero/bin after successful build. Removes existing file at destination before copying.

Source

pub fn output_dir<P: AsRef<Path>>(self, path: P) -> Self

Set a custom output directory for copying (instead of /hero/bin). Tilde () in paths will be expanded to home directory.

Source

pub fn arg(self, arg: impl Into<String>) -> Self

Add extra arguments to pass to cargo.

Source

pub fn verbose(self) -> Self

Enable verbose output.

Source

pub fn discover(&mut self) -> BuilderResult<&CargoMetadata>

Discovers Cargo.toml and parses metadata. Called automatically by build() if not called explicitly.

Source

pub fn cargo_toml_path(&self) -> Option<&Path>

Returns the path to Cargo.toml (after discovery).

Source

pub fn project_root(&self) -> Option<&Path>

Returns the project root directory (parent of Cargo.toml).

Source

pub fn metadata(&self) -> Option<&CargoMetadata>

Returns parsed cargo metadata (after discovery).

Source

pub fn list_binaries(&mut self) -> BuilderResult<Vec<BinaryTarget>>

Lists all available binaries in the project.

Source

pub fn build(self) -> BuilderResult<BuildResult>

Executes the build with configured options.

Trait Implementations§

Source§

impl Clone for RustBuilder

Source§

fn clone(&self) -> RustBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RustBuilder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for RustBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = 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.