wip
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "nats"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
async-nats = { version = "0.46.0" }
|
||||
@@ -0,0 +1 @@
|
||||
pub mod functions;
|
||||
@@ -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
@@ -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,2 +1,3 @@
|
||||
pub mod jobs;
|
||||
pub mod misc;
|
||||
pub mod queue;
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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>,
|
||||
}
|
||||
Reference in New Issue
Block a user