pub struct CargoTarget {
pub name: String,
pub display_name: String,
pub manifest_path: PathBuf,
pub kind: TargetKind,
pub extended: bool,
pub origin: Option<TargetOrigin>,
}Fields§
§name: String§display_name: String§manifest_path: PathBuf§kind: TargetKind§extended: bool§origin: Option<TargetOrigin>Implementations§
Source§impl CargoTarget
impl CargoTarget
Sourcepub fn from_source_file(
stem: &OsStr,
file_path: &Path,
manifest_path: &Path,
example: bool,
extended: bool,
) -> Option<Self>
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.
Sourcepub fn figure_main_name(&mut self)
pub fn figure_main_name(&mut self)
Updates the target’s name and display_name by interrogating the candidate file and its manifest.
Sourcepub fn from_folder(
folder: &Path,
manifest_path: &Path,
example: bool,
_extended: bool,
) -> Option<Self>
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:
- A file named
<folder_name>.rsin the folder. src/main.rsinside the folder.main.rsat the folder root.- Otherwise, it scans the folder for any
.rsfile 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.
Sourcepub fn refined_target(target: &CargoTarget) -> CargoTarget
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.
Sourcepub fn expand_subproject(target: &CargoTarget) -> Result<Vec<CargoTarget>>
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>.
Sourcepub fn expand_subprojects_in_place(
targets_map: &mut HashMap<(String, String), CargoTarget>,
) -> Result<()>
pub fn expand_subprojects_in_place( targets_map: &mut HashMap<(String, String), CargoTarget>, ) -> Result<()>
Expands subproject targets in the given map.
For every target with a SubProject origin, this function removes the original target,
expands it using expand_subproject, and then inserts the expanded targets.
The expanded targets have their display names modified to include the original folder name as a prefix.
This version replaces any existing target with the same key.
Sourcepub fn target_key(target: &CargoTarget) -> (String, String)
pub fn target_key(target: &CargoTarget) -> (String, String)
Creates a unique key for a target based on its manifest path and name.
Sourcepub fn expand_subproject_into_map(
target: &CargoTarget,
map: &mut HashMap<(String, String), CargoTarget>,
) -> Result<(), Box<dyn Error>>
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.
Sourcepub fn is_example(&self) -> bool
pub fn is_example(&self) -> bool
Returns true if the target is an example.
Trait Implementations§
Source§impl Clone for CargoTarget
impl Clone for CargoTarget
Source§fn clone(&self) -> CargoTarget
fn clone(&self) -> CargoTarget
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CargoTarget
impl RefUnwindSafe for CargoTarget
impl Send for CargoTarget
impl Sync for CargoTarget
impl Unpin for CargoTarget
impl UnwindSafe for CargoTarget
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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