[PR #177] [MERGED] Serialize enum as number #290

Closed
opened 2026-02-27 20:24:07 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ramsayleung/rspotify/pull/177
Author: @ramsayleung
Created: 1/13/2021
Status: Merged
Merged: 1/18/2021
Merged by: @marioortizmanero

Base: masterHead: ramsay_serialize_enum_to_int


📝 Commits (10+)

  • a40b488 add modality enum
  • 35664b1 change mode from f32 to enum Modality
  • e3734d9 add comments
  • 68691fb Update CHANGELOG
  • bf52cfe add test for AudioAnalysisTrack
  • 9284618 fix cargo fmt error
  • 97c3a32 Move Duration serializer/deserializer into mod duration_ms
  • f10723c Move millisecond_timestamp deserializer/serializer into mod millisecond_timestamp
  • ea9f514 Move option_duration_ms deserializer/serializer into mod option_duration_ms
  • bbcba86 Update CHANGELOG

📊 Changes

9 files changed (+212 additions, -158 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 src/model/audio.rs (+8 -9)
📝 src/model/context.rs (+5 -20)
📝 src/model/enums/misc.rs (+12 -0)
📝 src/model/mod.rs (+140 -97)
📝 src/model/offset.rs (+2 -5)
📝 src/model/show.rs (+4 -16)
📝 src/model/track.rs (+3 -11)
📝 tests/test_models.rs (+36 -0)

📄 Description

Description

  • AudioAnalysisSection::mode, AudioAnalysisTrack::mode and AudioFeatures::mode are f32s but should be Modality where enum Modality { Major, Minor, NoResult }
  • Move from(to)_millisecond_timestamp into its module millisecond_timestamp and rename them to deserialize & serialize
  • Move from(to)_duration_ms into its module duration_ms and rename them to deserialize & serialize
  • Move from(to)_option_duration_ms into its module option_duration_ms and rename them to deserialize & serialize

Motivation and Context

To make the API more ergonomic and easier to use.

Dependencies

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

Please also list any relevant details for your test configuration

  • AudioAnalysisSection: test_audio_analysis_section
  • AudioFeatures: test_audio_features
  • AudioAnalysisTrack: test_audio_analysis_track

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ramsayleung/rspotify/pull/177 **Author:** [@ramsayleung](https://github.com/ramsayleung) **Created:** 1/13/2021 **Status:** ✅ Merged **Merged:** 1/18/2021 **Merged by:** [@marioortizmanero](https://github.com/marioortizmanero) **Base:** `master` ← **Head:** `ramsay_serialize_enum_to_int` --- ### 📝 Commits (10+) - [`a40b488`](https://github.com/ramsayleung/rspotify/commit/a40b488309eb741819a376174c8f25169575f521) add `modality` enum - [`35664b1`](https://github.com/ramsayleung/rspotify/commit/35664b10e990574cf517b42c07dd0f177e22c740) change `mode` from f32 to enum `Modality` - [`e3734d9`](https://github.com/ramsayleung/rspotify/commit/e3734d9ade613e662b493285fd8d0f39c1bf32b1) add comments - [`68691fb`](https://github.com/ramsayleung/rspotify/commit/68691fb27b2314430c957c6d68d9b0044e6fb195) Update CHANGELOG - [`bf52cfe`](https://github.com/ramsayleung/rspotify/commit/bf52cfefe88a96cf428f3105f5ab0be5460d9d5b) add test for AudioAnalysisTrack - [`9284618`](https://github.com/ramsayleung/rspotify/commit/9284618c18d8277f7bae7db0c222f3e1baa79bc2) fix cargo fmt error - [`97c3a32`](https://github.com/ramsayleung/rspotify/commit/97c3a32d63e39a89f08f1f0d348cb914a0aba7f6) Move Duration serializer/deserializer into mod duration_ms - [`f10723c`](https://github.com/ramsayleung/rspotify/commit/f10723cb10f08d70d527b937f653e3c0f2f52ebc) Move millisecond_timestamp deserializer/serializer into mod millisecond_timestamp - [`ea9f514`](https://github.com/ramsayleung/rspotify/commit/ea9f514a768c61036614da0e00dc4415f274b92a) Move option_duration_ms deserializer/serializer into mod option_duration_ms - [`bbcba86`](https://github.com/ramsayleung/rspotify/commit/bbcba86261e468c22f610c8b16c749a88a8e53eb) Update CHANGELOG ### 📊 Changes **9 files changed** (+212 additions, -158 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `src/model/audio.rs` (+8 -9) 📝 `src/model/context.rs` (+5 -20) 📝 `src/model/enums/misc.rs` (+12 -0) 📝 `src/model/mod.rs` (+140 -97) 📝 `src/model/offset.rs` (+2 -5) 📝 `src/model/show.rs` (+4 -16) 📝 `src/model/track.rs` (+3 -11) 📝 `tests/test_models.rs` (+36 -0) </details> ### 📄 Description ## Description + `AudioAnalysisSection::mode`, `AudioAnalysisTrack::mode` and `AudioFeatures::mode` are f32s but should be `Modality` where `enum Modality { Major, Minor, NoResult }` + Move `from(to)_millisecond_timestamp` into its module `millisecond_timestamp` and rename them to `deserialize` & `serialize` + Move `from(to)_duration_ms` into its module `duration_ms` and rename them to `deserialize` & `serialize` + Move `from(to)_option_duration_ms` into its module `option_duration_ms` and rename them to `deserialize` & `serialize` ## Motivation and Context To make the API more ergonomic and easier to use. ## Dependencies ## Type of change Please delete options that are not relevant. - [x] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [x] This change requires a documentation update ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [x] `AudioAnalysisSection`: `test_audio_analysis_section` - [x] `AudioFeatures`: `test_audio_features` - [x] `AudioAnalysisTrack`: `test_audio_analysis_track` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:24:07 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/rspotify#290
No description provided.