Channelsc

This commit is contained in:
2026-08-19 03:10:35 +02:00
parent e5c5d7265a
commit c37e9d0fde
5 changed files with 48 additions and 11 deletions
+14 -1
View File
@@ -2,7 +2,7 @@ use std::{collections::HashSet, path::PathBuf};
use serde::{Deserialize, Serialize};
use crate::protocol::ServerMeta;
use crate::types::{Channel, ChannelKind, ServerMeta};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Config {
@@ -18,6 +18,19 @@ impl Config {
meta: ServerMeta {
name: "New Server".to_string(),
description: String::new(),
channels: vec![Channel {
id: "text-channels".to_string(),
name: "Text Channels".to_string(),
data: ChannelKind::Category {
channels: vec![Channel {
id: "general".to_string(),
name: "General".to_string(),
data: ChannelKind::Text,
}],
},
}],
},
port: 3415,
+1
View File
@@ -2,6 +2,7 @@ pub mod config;
pub mod protocol;
pub mod server;
pub mod signature;
pub mod types;
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
+2 -9
View File
@@ -4,17 +4,10 @@ use axum::extract::ws::{Message, Utf8Bytes, WebSocket};
use serde::{Deserialize, Serialize};
use tokio::sync::Mutex;
use crate::types::ClientMeta;
pub mod initialize;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClientMeta {}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServerMeta {
pub name: String,
pub description: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "method")]
pub enum ClientMethod {
+2 -1
View File
@@ -12,7 +12,8 @@ use tokio::sync::Mutex;
use crate::{
config::Config,
protocol::{ClientMeta, ClientMethod, read_loop, send_socket},
protocol::{ClientMethod, read_loop, send_socket},
types::ClientMeta,
};
pub struct UserConnections {
+29
View File
@@ -0,0 +1,29 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClientMeta {}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServerMeta {
pub name: String,
pub description: String,
pub channels: Vec<Channel>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "kind")]
#[serde(rename_all = "camelCase")]
pub enum ChannelKind {
Text,
Category { channels: Vec<Channel> },
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Channel {
pub id: String,
pub name: String,
#[serde(flatten)]
pub data: ChannelKind,
}