pub struct EntityRef {
pub kind: EntityKind,
pub key: String,
}Expand description
A stable way to name an entity, independent of any scan.
The key is what the thing calls itself rather than where it currently sits:
a path for a track, the release key for an album, the normalized name for
name-based entities. Recordings, works and release groups use an explicit
MusicBrainz identifier when the catalog has one. Source-only artists and
canonical credit exclusions may also use mbid:<identifier>.
Fields§
§kind: EntityKindWhich kind of thing is named.
key: StringIts stable key, in the spelling EntityRef builds.
Implementations§
Source§impl EntityRef
impl EntityRef
Sourcepub fn new(kind: EntityKind, key: impl Into<String>) -> EntityRef
pub fn new(kind: EntityKind, key: impl Into<String>) -> EntityRef
Builds a reference by hand, for a key already in the right shape.
Sourcepub fn to_token(&self) -> String
pub fn to_token(&self) -> String
How the reference is written in one token: track:/music/a.flac.
The kind comes first and the key may itself contain colons — a path does — so the split is on the first one only.
Sourcepub fn parse_token(text: &str) -> Option<EntityRef>
pub fn parse_token(text: &str) -> Option<EntityRef>
Reads back what EntityRef::to_token wrote.
Sourcepub fn of(catalog: &Catalog, kind: EntityKind, id: Id) -> Option<EntityRef>
pub fn of(catalog: &Catalog, kind: EntityKind, id: Id) -> Option<EntityRef>
The reference naming an entity of a catalog, if that entity exists.
Sourcepub fn resolve(&self, catalog: &Catalog) -> Option<Id>
pub fn resolve(&self, catalog: &Catalog) -> Option<Id>
The entity a reference names in this catalog, if it holds one.
Sourcepub fn display_name(&self, catalog: &Catalog) -> String
pub fn display_name(&self, catalog: &Catalog) -> String
How the thing is called on screen, or the key when it is gone.