Serial-ATA / Serial-ATA/lofty-rs

Change input value type from string to vec for better supporting multivalued tag

Open
#634 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
359
Forks
77
Avg merge
12h 54m
Merged PRs (30d)
11

Description

Summary

We now have a multivalued artist tag as shown below that needs to be written.
["小倉朝陽", 遥うみ", 八日堂朔莉", 坂リリ", 大蔵瑠美音", 遥そら", 桜小路亜十礼", "川崎美鳥"]
Under the current model, this is the only way we can write it.

let artists = vec!["小倉朝陽", "遥うみ", "八日堂朔莉", "坂リリ", "大蔵瑠美音", "遥そら", "桜小路亜十礼", "川崎美鳥"];

for artist in artists {
    source_tag.push("TrackArtist".to_string(), artist.to_string());
}

If we want to know if the original tag and the written tag are duplicates, we need to read them first and then make the judgment.

let artists = vec!["小倉朝陽", "遥うみ", "八日堂朔莉", "坂リリ", "大蔵瑠美音", "遥そら", "桜小路亜十礼", "川崎美鳥"];
let original_artists = source_tag.get_all("TrackArtist");
    
for original_artist in original_artists {
    if artists.contains(&original_artist) {
        ...
    }
}

If we change the input value into vec, we could parse the value like this. And the set mode is to overwrite, you will not care about whether the value is in original tag.

let artists = vec!["小倉朝陽", "遥うみ", "八日堂朔莉", "坂リリ", "大蔵瑠美音", "遥そら", "桜小路亜十礼", "川崎美鳥"];
source_tag.set_trackartist(&artists);

or

source_tag.set("TrackArtist".to_string(), &artists);

Moreover, there's the need to distinguish between single and multiple values, because even a single value can be passed into the vec, as is shown below.

let artists = vec!["小倉朝陽"];
source_tag.set_trackartist(&artists);

This change also allows for a unified external interface.

API design
pub fn set(&mut self, item_key: ItemKey, values: Vec<ItemValue>) {
        ....
}

Use this new api to instead the old api.

remove

pub fn insert()
pub fn insert_unchecked()
pub fn push()
pub fn push_unchecked()

Maybe it will remove more methods.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the tag API methods named in the issue, especially set, insert, insert_unchecked, push, and push_unchecked, and trace how ItemValue values are represented. The requested outcome is a unified set API accepting multiple values while supporting both single- and multivalued tags, with the scope of old-method removal resolved before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.