Skip to main content

suno_core/
lib.rs

1//! Core engine for rs-suno: library selection, sync reconciliation, and tagging.
2//!
3//! Runtime-agnostic and free of direct IO. Network access happens through the
4//! [`Http`] port, which a CLI adapter implements, so the engine stays testable
5//! in isolation.
6
7#![forbid(unsafe_code)]
8// Every public async method here is driven on the CLI's multi-threaded runtime,
9// so its future must be `Send`. Deny crate-wide (scoped to suno-core, not the
10// workspace) so a future that holds a non-`Send` value across an `.await` fails
11// the existing `clippy -D warnings` CI leg.
12#![deny(clippy::future_not_send)]
13// Make the never-panic contract auditable: in non-test library code every
14// unwrap/expect/panic/unreachable/todo/unimplemented is denied, so each
15// intentional site must carry an explicit `#[allow]` with a justification.
16#![cfg_attr(
17    not(test),
18    deny(
19        clippy::unwrap_used,
20        clippy::expect_used,
21        clippy::panic,
22        clippy::unreachable,
23        clippy::todo,
24        clippy::unimplemented
25    )
26)]
27
28mod album_art;
29mod area;
30mod auth;
31mod backoff;
32mod civil;
33mod client;
34mod clock;
35pub mod config;
36mod consts;
37pub mod desired;
38mod downloadable;
39mod error;
40mod executor;
41mod extras;
42mod ffmpeg;
43mod fs;
44mod graph;
45mod hash;
46mod http;
47mod identity;
48mod limiter;
49mod lineage;
50mod lyrics;
51mod manifest;
52mod model;
53mod naming;
54mod orphans;
55mod pathkey;
56pub mod reconcile;
57mod roots;
58pub mod select;
59mod synced;
60mod tag;
61mod tag_alac;
62mod textfmt;
63mod tracks;
64mod vocab;
65mod wire;
66
67#[cfg(test)]
68mod testutil;
69
70#[cfg(test)]
71mod sync_chaos;
72
73pub use album_art::{AlbumArt, PlaylistState};
74pub use area::{
75    AreaKind, AreaListing, adoption_enumerated, area_enumerated, area_mode, build_modes_by_id,
76    build_scoped_playlist_desired, library_authoritative, playlists_enumerated, source_statuses,
77    union_clips,
78};
79pub use auth::{ClerkAuth, TOKEN_EXPIRY_WARN_DAYS, TokenExpiry, classify_token_expiry};
80pub use civil::days_to_civil;
81pub use client::SunoClient;
82pub use clock::Clock;
83#[cfg(feature = "schema")]
84pub use config::config_schema_json;
85pub use config::{
86    AccountConfig, AreaMode, AreasConfig, Config, Defaults, EffectiveSettings, FlagOverrides,
87    Settings, SourceConfig, animated_covers_flag_overridden,
88};
89pub use desired::{
90    ArtifactToggles, LIKED_PLAYLIST_ID, PlaylistInput, album_desired, build_desired,
91    build_playlist_desired, clip_stems,
92};
93pub use downloadable::is_downloadable;
94pub use error::{Error, Result};
95pub use executor::{ExecOptions, ExecOutcome, Failure, Ports, RunStatus, execute};
96pub use extras::{
97    INDEX_SCHEMA_VERSION, M3u8Entry, render_clip_details, render_library_index, render_m3u8,
98};
99pub use ffmpeg::{Ffmpeg, FfmpegError, FfmpegErrorKind};
100pub use fs::{FileStat, Filesystem, FsError, FsErrorKind};
101pub use graph::{CacheEntry, LineageStore, Node, StoredEdge};
102pub use hash::{
103    SYNCED_LRC_VERSION, art_hash, art_url_hash, content_hash, lyrics_txt_source_hash, meta_hash,
104    synced_lrc_source_hash,
105};
106pub use http::{Http, HttpRequest, HttpResponse, Method, TransportError};
107pub use identity::{AdoptDecision, Owner, OwnerGate, adopt_decision, owner_gate};
108pub use lineage::{
109    AttributionEdge, Edge, EdgeRole, EdgeType, LineageContext, Resolution, ResolveStatus, RootInfo,
110    attribution_edges, edge_type, immediate_parent, lineage_edges,
111};
112pub use lyrics::{
113    AlignedLine, AlignedLineWord, AlignedLyrics, AlignedWord, render_clip_lrc, render_clip_lyrics,
114    render_synced_lrc,
115};
116pub use manifest::{ArtifactState, Manifest, ManifestEntry, SyncedLyricsCheck};
117pub use model::{BillingInfo, Clip, ClipRoot, HistoryEntry, MediaUrl, Playlist, Stem};
118pub use naming::{
119    CharacterSet, DEFAULT_TEMPLATE, NamingConfig, NamingRequest, RenderedName, render_clip_name,
120    render_clip_names, sanitise_name, stem_file_path, stems_folder,
121};
122pub use orphans::untracked_audio;
123pub use reconcile::{
124    Action, AlbumDesired, Desired, DesiredArtifact, DesiredStem, LocalFile, Plan, PlaylistDesired,
125    SourceStatus, area_authoritative, area_fully_enumerated, deletion_allowed, narrows_downloads,
126    plan_album_artifacts, plan_playlist_artifacts, reconcile,
127};
128pub use roots::{ResolveOpts, resolve_roots};
129pub use synced::{
130    PendingCheck, SYNCED_LRC_RECHECK_SECS, apply_synced_lrc, preview_synced_lrc,
131    synced_lyrics_targets,
132};
133pub use tag::{Cover, TrackMetadata, flac_picture_data_budget, tag_flac, tag_mp3};
134pub use tag_alac::tag_alac;
135pub use tracks::{LeadResolution, TrackAssignment, assign_track_numbers, resolve_lead_ids};
136pub use vocab::{
137    ArtifactKind, AudioFormat, SourceMode, StemFormat, VideoCoverRetention, WebpEncodeSettings,
138};