Skip to content

Suggestion: use a New-Type for the TrackId to avoid wrong usage #45

Description

@sassman

I was experimenting with using your tool as a lib, and I encountered something that was not clear to me from reading the docs:

let track = Track::new("6QLADdXYMjNHBLr8a9WE7y").expect("Failed to create track");

It failed, in the docs it was just written the argument to new is called track: &str.

Since I was not familiar with the spotify notation of "uris", I failed.

When writing it worked.

Track::new("spotify:track:6QLADdXYMjNHBLr8a9WE7y")

So instead of accepting a &str I would suggest to accept only a new type called TrackUri that would guide the user to prefix the track id with spotify:track: and can only be instantiated via TryFrom or a new that returns a result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions