[PR #673] [MERGED] Create separate discovery crate #1011

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

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/673
Author: @Johannesd3
Created: 3/14/2021
Status: Merged
Merged: 5/26/2021
Merged by: @roderickvd

Base: devHead: discovery-crate


📝 Commits (8)

  • ebea539 Add librespot-discovery crate
  • 1ec5dd2 Add discovery example
  • a7f9e0a Add an error type to librespot_discovery
  • 16de6a7 Improve api of discovery crate's builder
  • c49e132 Update workflow
  • 9b6ba49 Add "discovery" compat layer to "connect"
  • ceab363 Update changelog
  • 4448ce0 Set correct libraryVersion

📊 Changes

14 files changed (+583 additions, -298 deletions)

View changed files

📝 .github/workflows/test.yml (+2 -2)
📝 CHANGELOG.md (+7 -1)
📝 Cargo.lock (+51 -9)
📝 Cargo.toml (+5 -1)
📝 connect/Cargo.toml (+7 -14)
📝 connect/src/discovery.rs (+15 -247)
📝 connect/src/lib.rs (+4 -0)
📝 core/src/config.rs (+35 -22)
discovery/Cargo.toml (+40 -0)
discovery/examples/discovery.rs (+25 -0)
discovery/src/lib.rs (+150 -0)
discovery/src/server.rs (+236 -0)
📝 src/lib.rs (+1 -0)
📝 src/main.rs (+5 -2)

📄 Description

This PR splits out a new librespot-discovery crate out of librespot-connect. The original rationale was the fact that discovery and spirc don't have many dependencies in common. Probably they only belong to the same crate because Spotify sells them as one feature.

However, after the split was done, I wondered how the new crate could be improved and extended.

There might be other endpoints that we (at least I) don't know of, or they might be added in future, so my first aim was to make it easy to add them. I also thought of the possibility to add a client functionality to this crate. Therefore, I decided to create slightly overengineered Serialize and Deserialize implementations for arguments and responses. Those can be found in the modules request and response. I added unit tests to handle the additional complexity.

I tried to create a neat API surface, and added documentation for all public items.

I don't want this to get merged before #665 is merged into dev, so I keep it as a draft for now. But I'd really like to hear you feedback before I continue working on it. Do you think it is a worthwhile change, or is it getting too complicated?

This change is not breaking: The module librespot_connect::discovery remains as a compatibility layer for the new crate and will be deprecated. This module could be removed in a later breaking release.

PS: There's one concrete improvement: The server does not panic anymore on certain malformed requests.

Future possibilites

  • Generalize the API, so that users of the crate are able to use all information given to the addUser endpoint or to send custom error messages as response.
  • Add client functionality, possibly behind a feature flag

EDIT: After removing commit e3e60bb, most things don't apply anymore. It would be just a step into this direction.


🔄 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/librespot-org/librespot/pull/673 **Author:** [@Johannesd3](https://github.com/Johannesd3) **Created:** 3/14/2021 **Status:** ✅ Merged **Merged:** 5/26/2021 **Merged by:** [@roderickvd](https://github.com/roderickvd) **Base:** `dev` ← **Head:** `discovery-crate` --- ### 📝 Commits (8) - [`ebea539`](https://github.com/librespot-org/librespot/commit/ebea5397b9e763b5e2d3d5df824eae74ca7bbc62) Add librespot-discovery crate - [`1ec5dd2`](https://github.com/librespot-org/librespot/commit/1ec5dd21fa833d1c44805c29e807a0308d689c4a) Add discovery example - [`a7f9e0a`](https://github.com/librespot-org/librespot/commit/a7f9e0a20b512dcb7bb28e4eb31bd2c559c1b2d0) Add an error type to librespot_discovery - [`16de6a7`](https://github.com/librespot-org/librespot/commit/16de6a7f6876cf3fbc2f637f98272485eb0de9d5) Improve api of discovery crate's builder - [`c49e132`](https://github.com/librespot-org/librespot/commit/c49e1320d41d52375ebd65db813e3cff6a1bcce4) Update workflow - [`9b6ba49`](https://github.com/librespot-org/librespot/commit/9b6ba4902665ea9a908a7f14121f3c7ef3cb7216) Add "discovery" compat layer to "connect" - [`ceab363`](https://github.com/librespot-org/librespot/commit/ceab3634299b5e0e64482c030a808ae1afc63108) Update changelog - [`4448ce0`](https://github.com/librespot-org/librespot/commit/4448ce0c098252e509140c6cef0a4c7cbcac9669) Set correct libraryVersion ### 📊 Changes **14 files changed** (+583 additions, -298 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/test.yml` (+2 -2) 📝 `CHANGELOG.md` (+7 -1) 📝 `Cargo.lock` (+51 -9) 📝 `Cargo.toml` (+5 -1) 📝 `connect/Cargo.toml` (+7 -14) 📝 `connect/src/discovery.rs` (+15 -247) 📝 `connect/src/lib.rs` (+4 -0) 📝 `core/src/config.rs` (+35 -22) ➕ `discovery/Cargo.toml` (+40 -0) ➕ `discovery/examples/discovery.rs` (+25 -0) ➕ `discovery/src/lib.rs` (+150 -0) ➕ `discovery/src/server.rs` (+236 -0) 📝 `src/lib.rs` (+1 -0) 📝 `src/main.rs` (+5 -2) </details> ### 📄 Description This PR splits out a new `librespot-discovery` crate out of `librespot-connect`. The original rationale was the fact that discovery and spirc don't have many dependencies in common. Probably they only belong to the same crate because Spotify sells them as one feature. However, after the split was done, I wondered how the new crate could be improved and extended. ~There might be other endpoints that we (at least I) don't know of, or they might be added in future, so my first aim was to make it easy to add them. I also thought of the possibility to add a client functionality to this crate. Therefore, I decided to create slightly overengineered `Serialize` and `Deserialize` implementations for arguments and responses. Those can be found in the modules `request` and `response`. I added unit tests to handle the additional complexity.~ I tried to create a neat API surface, and added documentation for all public items. ~I don't want this to get merged before #665 is merged into dev, so I keep it as a draft for now. But I'd really like to hear you feedback before I continue working on it. Do you think it is a worthwhile change, or is it getting too complicated?~ _This change is not breaking_: The module `librespot_connect::discovery` remains as a compatibility layer for the new crate and will be deprecated. This module could be removed in a later breaking release. ~PS: There's one concrete improvement: The server does not panic anymore on certain malformed requests.~ ### Future possibilites * Generalize the API, so that users of the crate are able to use all information given to the addUser endpoint or to send custom error messages as response. * Add client functionality, possibly behind a feature flag **EDIT:** After removing commit e3e60bb, most things don't apply anymore. It would be just a step into this direction. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:00:49 +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/librespot#1011
No description provided.