Merge pull request #83 from michel/lib/api-hygiene

refactor(lib): keep the actors inside the crate and mark the growing enums
This commit is contained in:
Michel de Graaf
2026-09-08 02:06:33 +02:00
committed by GitHub
7 changed files with 27 additions and 15 deletions
+3 -3
View File
@@ -115,6 +115,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
``` ```
`ServerMessage` and `ClientOperation` are `#[non_exhaustive]`: every protocol `ClientOperation` is `#[non_exhaustive]`: every protocol message the client
message the client learns to handle adds a variant, so match them with a learns to handle adds a variant, so match it with a wildcard arm. `SharedFile`
wildcard arm. is too, so build it with the `..` syntax rather than listing every field.
+1 -1
View File
@@ -52,7 +52,7 @@ impl<M: Send> ActorHandle<M> {
} }
/// Internal actor message wrapper /// Internal actor message wrapper
pub(crate) enum ActorMessage<M> { pub enum ActorMessage<M> {
UserMessage(M), UserMessage(M),
Stop, Stop,
} }
+9 -5
View File
@@ -2,14 +2,17 @@
// example in it, so a signature change cannot leave the advertised usage stale. // example in it, so a signature change cannot leave the advertised usage stale.
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
// Core modules // The public surface is the client, its types, the wire codec and the share
pub mod actor; // index. The actors, dispatcher, peer plumbing and download store are how the
// client is built, not what a host programs against, so they stay inside the
// crate and a change to them is not a change to the library's API.
pub(crate) mod actor;
pub mod client; pub mod client;
pub mod dispatcher; pub(crate) mod dispatcher;
pub mod download_store; pub(crate) mod download_store;
pub mod error; pub mod error;
pub mod message; pub mod message;
pub mod peer; pub(crate) mod peer;
pub mod shares; pub mod shares;
pub mod types; pub mod types;
#[macro_use] #[macro_use]
@@ -31,6 +34,7 @@ pub use actor::server_actor::{PeerAddress, UserMessage};
pub use client::{Client, ClientSettings}; pub use client::{Client, ClientSettings};
pub use error::{Result, SoulseekRs}; pub use error::{Result, SoulseekRs};
pub use message::peer::{SharedDirectory, SharedFileEntry}; pub use message::peer::{SharedDirectory, SharedFileEntry};
pub use peer::{ConnectionType, ParseConnectionTypeError};
pub use types::{ pub use types::{
ClientVersion, DownloadStatus, File, RoomEvent, RoomInfo, Search, ClientVersion, DownloadStatus, File, RoomEvent, RoomInfo, Search,
SearchResult, SessionLoss, Transfer, UploadInfo, UploadStatus, UserInfo, SearchResult, SessionLoss, Transfer, UploadInfo, UploadStatus, UserInfo,
+2 -3
View File
@@ -3,10 +3,9 @@ pub mod listen;
pub mod upload_peer; pub mod upload_peer;
// Export actor types // Export actor types
pub use crate::actor::peer_actor::{PeerActor, PeerMessage}; pub use crate::actor::peer_actor::PeerMessage;
pub use crate::actor::peer_registry::PeerRegistry;
pub(crate) use download_peer::part_path_of; pub use download_peer::part_path_of;
pub use download_peer::{DownloadError, DownloadPeer}; pub use download_peer::{DownloadError, DownloadPeer};
use crate::message::Message; use crate::message::Message;
+4
View File
@@ -12,7 +12,11 @@ use std::io;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
/// One shared file: its peer-facing virtual path and where it lives on disk. /// One shared file: its peer-facing virtual path and where it lives on disk.
///
/// Built by the scan, never by a host, so fields can be added without a
/// breaking release.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[non_exhaustive]
pub struct SharedFile { pub struct SharedFile {
/// Backslash-separated path exposed to peers, e.g. `music\album\song.mp3`. /// Backslash-separated path exposed to peers, e.g. `music\album\song.mp3`.
pub virtual_path: String, pub virtual_path: String,
+2 -3
View File
@@ -24,10 +24,9 @@ use std::time::{Duration, Instant};
use soulseek_rs::message::Message; use soulseek_rs::message::Message;
use soulseek_rs::message::server::MessageFactory; use soulseek_rs::message::server::MessageFactory;
use soulseek_rs::peer::ConnectionType;
use soulseek_rs::{ use soulseek_rs::{
Client, ClientSettings, ClientVersion, DownloadStatus, PeerAddress, Client, ClientSettings, ClientVersion, ConnectionType, DownloadStatus,
SessionLoss, UploadStatus, PeerAddress, SessionLoss, UploadStatus,
}; };
/// Only one test at a time may drive a server. /// Only one test at a time may drive a server.
+6
View File
@@ -172,7 +172,11 @@ pub struct Cli {
pub log_file: Option<PathBuf>, pub log_file: Option<PathBuf>,
} }
/// Non-exhaustive: this enum is public through the crate's library target so
/// the integration tests can reach it, and a new subcommand must not read as a
/// breaking change of that library.
#[derive(Subcommand, Debug)] #[derive(Subcommand, Debug)]
#[non_exhaustive]
pub enum Commands { pub enum Commands {
/// Search the network and print matching files /// Search the network and print matching files
Search(SearchArgs), Search(SearchArgs),
@@ -254,6 +258,7 @@ pub struct DaemonArgs {
} }
#[derive(Subcommand, Debug)] #[derive(Subcommand, Debug)]
#[non_exhaustive]
pub enum DaemonCommand { pub enum DaemonCommand {
/// Print the token remote clients authenticate with /// Print the token remote clients authenticate with
Token, Token,
@@ -266,6 +271,7 @@ pub enum DaemonCommand {
} }
#[derive(Subcommand, Debug)] #[derive(Subcommand, Debug)]
#[non_exhaustive]
pub enum CompletionsCommand { pub enum CompletionsCommand {
/// Write the completion script where the shell looks for it /// Write the completion script where the shell looks for it
Install(CompletionsArgs), Install(CompletionsArgs),