zero4rs 2.0.0

zero4rs is a powerful, pragmatic, and extremely fast web framework for Rust
Documentation
use tokio::sync::{mpsc, oneshot};

use super::{
    input::{PostLocationData, SubscribeChannel, TalkMessage},
    output::{Level, Ty},
    ConnId, Msg, UserInfo,
};

// message type
#[derive(serde::Serialize, serde::Deserialize)]
pub struct Broadcast {
    pub level: Level,
    pub ty: Ty,
    pub msg: Msg,
}

/// A command received by the [`ChatServer`].
#[derive(Debug)]
pub enum Command {
    Connect {
        conn_tx: mpsc::UnboundedSender<Msg>,
        res_tx: oneshot::Sender<ConnId>,
        user_info: UserInfo,
    },

    Autorization {
        id: Option<String>,
        conn: ConnId,
        token: String,
    },

    Disconnect {
        conn: ConnId,
    },

    Message {
        msg: Msg,
        conn: ConnId,
    },

    Total {
        res_tx: oneshot::Sender<usize>,
    },

    OnlineUsers {
        res_tx: oneshot::Sender<Vec<String>>,
    },

    AllConnections {
        res_tx: oneshot::Sender<Vec<(String, String, String)>>,
    },

    Closed {
        conn: ConnId,
    },

    Broadcast {
        level: Level,
        ty: Ty,
        msg: Msg,
    },

    Servertime {
        msg: Msg,
    },

    Subscribe {
        id: Option<String>,
        conn: ConnId,
        channel: SubscribeChannel,
    },

    Unsubscribe {
        id: Option<String>,
        conn: ConnId,
        channel: SubscribeChannel,
    },

    TalkMsg {
        id: Option<String>,
        conn: ConnId,
        curr_user: UserInfo,
        msg: TalkMessage,
    },

    HistoryMsg {
        id: Option<String>,
        conn: ConnId,
        to: String,
    },

    HistoryTalk {
        id: Option<String>,
        conn: ConnId,
    },

    Location {
        id: Option<String>,
        conn: ConnId,
        msg: PostLocationData,
    },
}