Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Improvements #130

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

XML Improvements #130

wants to merge 6 commits into from

Conversation

Holzhaus
Copy link
Owner

@Holzhaus Holzhaus commented Feb 2, 2025

No description provided.

Copy link
Contributor

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

large lgtm, couple thoughts

Comment on lines +173 to +174
let document: rekordcrate::xml::Document =
quick_xml::de::from_reader(reader).expect("failed to deserialize XML");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you figured out how to avoid the expect here yet? (the thing I criticized in the previous PR).

Comment on lines +74 to +95
impl Serialize for Collection {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
#[derive(Serialize)]
struct Value<'a> {
/// Number of TRACK in COLLECTION
#[serde(rename = "@Count")]
entries: usize,
/// Tracks
#[serde(rename = "TRACK")]
tracks: &'a Vec<Track>,
}

let value = Value {
entries: self.tracks.len(),
tracks: &self.tracks,
};

value.serialize(serializer)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this could be simplified by using #[serde(getter = "tracks.len()")] instead?

Comment on lines +82 to +83
#[serde(rename = "@Count")]
entries: usize,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message doesn't explain why this is now @Count when it was previously @Entries. Can you elaborate?

Self::Turquoise => write!(f, "Turquoise"),
Self::Blue => write!(f, "Blue"),
Self::Violet => write!(f, "Violet"),
Self::Custom(rgb) => write!(f, "#{:02X}{:02X}{:02X}", rgb.r, rgb.g, rgb.b),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative: delegate to the inner type if you don't need a stable representation
https://docs.rs/rgb/latest/rgb/type.RGB8.html#impl-Display-for-Rgb%3CT%3E

Suggested change
Self::Custom(rgb) => write!(f, "#{:02X}{:02X}{:02X}", rgb.r, rgb.g, rgb.b),
Self::Custom(rgb) => write!(f, "{}", rgb),

Comment on lines +380 to 393
pub enum StarRating {
/// Zero Stars
Zero = 0x00,
/// One Star
One = 0x33,
/// Two Stars
Two = 0x66,
/// Three Stars
Three = 0x99,
/// Four Stars
Four = 0xCC,
/// Five Stars
Five = 0xFF,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is a u8 under the hood, do fractional stars also exist (eg 230 corresponding to roughly 4.5 stars)? Do those need to be modeled here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants