This commit is contained in:
2026-03-12 01:03:44 +01:00
parent 2f6f8414d0
commit 8ed01f2049
15 changed files with 180 additions and 15 deletions
+7
View File
@@ -0,0 +1,7 @@
[package]
name = "nats"
version = "0.1.0"
edition = "2024"
[dependencies]
async-nats = { version = "0.46.0" }
+1
View File
@@ -0,0 +1 @@
pub fn()
+1
View File
@@ -0,0 +1 @@
pub mod functions;
+1
View File
@@ -5,4 +5,5 @@ edition = "2024"
[dependencies]
serde = { version = "1.0.228" }
url = { version = "2.5.8", features = ["serde"] }
uuid = { version = "1.22.0", features = ["serde", "v4"] }
+21 -5
View File
@@ -1,18 +1,34 @@
use std::{num::NonZeroU64, path::PathBuf};
use serde::{Deserialize, Serialize};
use url::Url;
use uuid::Uuid;
use crate::queue::YoutubeSong;
pub enum JobsBody {
}
impl Jobs {
fn as_str(&self) -> &'static str {
match self {
Self::Search(self) => "Hello",
Self::Download => "World",
}
}
}
#[derive(Debug, Deserialize, Serialize)]
pub enum Jobs {
Search(SearchResponse),
Download(DownloadResponse),
Play(PlayResponse),
// Error(String),
}
pub type JobResult = Result<Jobs, String>;
#[derive(Serialize, Deserialize, Debug)]
pub struct JobResponse<T = Jobs> {
pub content: Option<T>,
@@ -22,7 +38,7 @@ pub struct JobResponse<T = Jobs> {
#[derive(Serialize, Deserialize, Debug)]
pub struct DownloadJob {
pub uuid: Uuid,
pub url: String,
pub url: Url,
}
#[derive(Serialize, Deserialize, Debug)]
@@ -49,5 +65,5 @@ pub struct SearchJob {
#[derive(Serialize, Deserialize, Debug)]
pub struct SearchResponse {
pub url: String,
pub song: YoutubeSong,
}
+1
View File
@@ -1,2 +1,3 @@
pub mod jobs;
pub mod misc;
pub mod queue;
+5
View File
@@ -1,5 +1,10 @@
use url::Url;
use uuid::Uuid;
pub fn new_uuid_v4() -> Uuid {
Uuid::new_v4()
}
pub fn parse_url_or_default(url_string: String) -> Url {
Url::parse(url_string.as_str()).unwrap_or(Url::parse("https://example.com").unwrap())
}
+27
View File
@@ -0,0 +1,27 @@
use std::num::NonZeroU64;
use serde::{Deserialize, Serialize};
use url::Url;
use uuid::Uuid;
#[derive(Serialize, Deserialize, Debug)]
pub struct YoutubeSong {
pub title: String,
pub artist: String,
pub url: Url,
pub thumbnail_url: Url,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct YoutubePlaylist {
pub title: String,
pub songs: Vec<YoutubeSong>,
pub url: Url,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Queue {
pub uuid: Uuid,
pub guild_id: NonZeroU64,
pub songs: Vec<YoutubeSong>,
}