CargoTarget

Struct CargoTarget 

Source
pub struct CargoTarget {
    pub name: String,
    pub display_name: String,
    pub manifest_path: PathBuf,
    pub kind: TargetKind,
    pub extended: bool,
    pub toml_specified: bool,
    pub origin: Option<TargetOrigin>,
}

Fields§

§name: String§display_name: String§manifest_path: PathBuf§kind: TargetKind§extended: bool§toml_specified: bool§origin: Option<TargetOrigin>

Implementations§

Source§

impl CargoTarget

Source

pub fn display_label(&self) -> String

Full display label, with a * suffix when toml_specified.

Source

pub fn from_source_file( stem: &OsStr, file_path: &Path, manifest_path: &Path, example: bool, extended: bool, ) -> Option<Self>

Constructs a CargoTarget from a source file.

Reads the file at file_path and determines the target kind based on:

  • Tauri configuration (e.g. if the manifest’s parent is “src-tauri” or a Tauri config exists),
  • Dioxus markers in the file contents,
  • And finally, if the file contains “fn main”, using its parent directory (examples vs bin) to decide.

If none of these conditions are met, returns None.

Source

pub fn figure_main_name(&mut self) -> Result<()>

Source

pub fn from_folder( folder: &Path, manifest_path: &Path, example: bool, _extended: bool, ) -> Option<Self>

Constructs a CargoTarget from a folder by trying to locate a runnable source file.

The function attempts the following candidate paths in order:

  1. A file named <folder_name>.rs in the folder.
  2. src/main.rs inside the folder.
  3. main.rs at the folder root.
  4. Otherwise, it scans the folder for any .rs file containing "fn main".

Once a candidate is found, it reads its contents and calls determine_target_kind to refine the target kind based on Tauri or Dioxus markers. The extended flag indicates whether the target should be marked as extended (for instance, if the folder is a subdirectory of the primary “examples” or “bin” folder).

Returns Some(CargoTarget) if a runnable file is found, or None otherwise.

Source

pub fn refined_target(target: &CargoTarget) -> CargoTarget

Returns a refined CargoTarget based on its file contents and location. This function is pure; it takes an immutable CargoTarget and returns a new one. If the target’s origin is either SingleFile or DefaultBinary, it reads the file and uses determine_target_kind to update the kind accordingly.

Source

pub fn expand_subproject(target: &CargoTarget) -> Result<Vec<CargoTarget>>

Expands a subproject CargoTarget into multiple runnable targets.

If the given target’s origin is a subproject (i.e. its Cargo.toml is in a subfolder), this function loads that Cargo.toml and uses get_runnable_targets to discover its runnable targets. It then flattens and returns them as a single Vec<CargoTarget>.

Source

pub fn expand_subprojects_in_place( targets_map: &mut HashMap<(String, String), CargoTarget>, ) -> Result<()>

Source

pub fn target_key(target: &CargoTarget) -> (String, String)

Creates a unique key for a target based on its manifest path and name.

Source

pub fn expand_subproject_into_map( target: &CargoTarget, map: &mut HashMap<(String, String), CargoTarget>, ) -> Result<(), Box<dyn Error>>

Expands a subproject target into multiple targets and inserts them into the provided HashMap, using (manifest, name) as a key to avoid duplicates.

Source

pub fn is_example(&self) -> bool

Returns true if the target is an example.

Trait Implementations§

Source§

impl Clone for CargoTarget

Source§

fn clone(&self) -> CargoTarget

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 CargoTarget

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,