pub struct Target { /* private fields */ }Expand description
A resolved metadata target consisting of a type and an optional value.
Implementations§
Source§impl Target
impl Target
Sourcepub fn from_parts(target_type: TargetType, value: Option<String>) -> Self
pub fn from_parts(target_type: TargetType, value: Option<String>) -> Self
Create a target from raw parts.
This is a low-level constructor used when the target type and value are
already known (e.g., when reconstructing targets from database rows or
parsed tree entries). For user-facing construction, prefer the named
constructors (commit(), project(), etc.)
or parse().
§Parameters
target_type: the kind of targetvalue: the target value, orNonefor project targets
Sourcepub fn parse(s: &str) -> Result<Self>
pub fn parse(s: &str) -> Result<Self>
Parse a target from a string in type:value format (e.g. "commit:abc123").
This is the CLI-oriented constructor. For programmatic use, prefer the
named constructors: commit(), project(),
path(), branch(), change_id().
§Parameters
s: the target string intype:valueformat, or"project"for project targets.
§Errors
Returns an error if the format is invalid, the target type is unknown, or the value is shorter than 3 characters.
Sourcepub fn target_type(&self) -> &TargetType
pub fn target_type(&self) -> &TargetType
The type of this target (commit, branch, path, etc.).
Sourcepub fn value(&self) -> Option<&str>
pub fn value(&self) -> Option<&str>
The target’s value, if any.
Returns None for project targets, Some(sha) for commit targets, etc.
Sourcepub fn resolve(&self, repo: &Repository) -> Result<Target>
pub fn resolve(&self, repo: &Repository) -> Result<Target>
If this is a commit target with a partial SHA, expand it to 40 chars using the given Git repository. Returns a new target with the expanded SHA, or a clone of this target if no resolution is needed.
Trait Implementations§
impl Eq for Target
impl StructuralPartialEq for Target
Auto Trait Implementations§
impl Freeze for Target
impl RefUnwindSafe for Target
impl Send for Target
impl Sync for Target
impl Unpin for Target
impl UnsafeUnpin for Target
impl UnwindSafe for Target
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.