feat: add `ArtifactId::identifier()` (#1087)
* feat: add `ArtifactId::identifier()` * docs: note that `slug` is not unique * chore: remove --all from clippy Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
This commit is contained in:
parent
967a142563
commit
7842a70803
|
@ -126,7 +126,7 @@ jobs:
|
|||
- name: cargo fmt
|
||||
run: cargo +nightly-2022-03-20 fmt --all -- --check
|
||||
- name: cargo clippy
|
||||
run: cargo +nightly-2022-03-20 clippy --all --all-features -- -D warnings
|
||||
run: cargo +nightly-2022-03-20 clippy --all-features -- -D warnings
|
||||
|
||||
wasm:
|
||||
name: WASM
|
||||
|
|
|
@ -36,9 +36,18 @@ pub struct ArtifactId {
|
|||
|
||||
impl ArtifactId {
|
||||
/// Returns a <filename>:<name> slug that identifies an artifact
|
||||
///
|
||||
/// Note: This identifier is not necessarily unique. If two contracts have the same name, they
|
||||
/// will share the same slug. For a unique identifier see [ArtifactId::identifier].
|
||||
pub fn slug(&self) -> String {
|
||||
format!("{}.json:{}", self.path.file_stem().unwrap().to_string_lossy(), self.name)
|
||||
}
|
||||
|
||||
/// Returns a <source path>:<name> slug that uniquely identifies an artifact
|
||||
pub fn identifier(&self) -> String {
|
||||
format!("{}:{}", self.source.to_string_lossy(), self.name)
|
||||
}
|
||||
|
||||
/// Returns a <filename><version>:<name> slug that identifies an artifact
|
||||
pub fn slug_versioned(&self) -> String {
|
||||
format!(
|
||||
|
|
Loading…
Reference in New Issue