flare-core 0.1.2

A high-performance, reliable long-connection communication toolkit for Rust, supporting WebSocket and QUIC protocols with features like authentication, device management, serialization negotiation, and protocol racing.
// This file is @generated by prost-build.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Command {
    #[prost(oneof = "command::Type", tags = "1, 2, 3, 4")]
    pub r#type: ::core::option::Option<command::Type>,
}
/// Nested message and enum types in `Command`.
pub mod command {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[serde(rename_all = "snake_case")]
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Type {
        /// 系统命令(连接、心跳、错误等)
        #[prost(message, tag = "1")]
        System(super::SystemCommand),
        /// 消息命令(发送、确认)
        #[prost(message, tag = "2")]
        Message(super::MessageCommand),
        /// 通知命令(广播、用户状态等)
        #[prost(message, tag = "3")]
        Notification(super::NotificationCommand),
        /// 自定义命令(业务扩展)
        #[prost(message, tag = "4")]
        Custom(super::CustomCommand),
    }
}
/// ------------------------------------------------------------
/// 系统命令
/// ------------------------------------------------------------
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SystemCommand {
    /// 命令类型(必需)
    #[prost(enumeration = "system_command::Type", tag = "1")]
    pub r#type: i32,
    /// 序列化格式(仅 CONNECT/CONNECT_ACK)
    #[prost(enumeration = "system_command::SerializationFormat", tag = "2")]
    pub format: i32,
    /// 说明信息(ERROR、EVENT、CLOSE、AUTH_ACK)
    #[prost(string, tag = "3")]
    pub message: ::prost::alloc::string::String,
    /// 附加参数(CONNECT、AUTH等)
    #[prost(map = "string, bytes", tag = "4")]
    pub metadata: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::vec::Vec<u8>,
    >,
    /// 数据载荷(EVENT、AUTH等)
    #[prost(bytes = "vec", tag = "5")]
    pub data: ::prost::alloc::vec::Vec<u8>,
}
/// Nested message and enum types in `SystemCommand`.
pub mod system_command {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[serde(rename_all = "snake_case")]
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Type {
        Unspecified = 0,
        /// 客户端请求连接 / 握手(需要 format、metadata)
        Connect = 1,
        /// 服务端确认连接(需要 format、metadata)
        ConnectAck = 2,
        /// 关闭连接(可选 message、metadata)
        Close = 3,
        /// 心跳请求(仅需 type)
        Ping = 4,
        /// 心跳响应(仅需 type)
        Pong = 5,
        /// 错误通知(需要 message,可选 metadata)
        Error = 6,
        /// 系统事件(需要 message,可选 metadata、data)
        Event = 7,
        /// 鉴权请求(需要 metadata,可选 data)
        Auth = 8,
        /// 鉴权响应(可选 message、metadata)
        AuthAck = 9,
        /// 被踢下线(需要 message 说明原因,可选 metadata)
        Kicked = 10,
    }
    impl Type {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Unspecified => "UNSPECIFIED",
                Self::Connect => "CONNECT",
                Self::ConnectAck => "CONNECT_ACK",
                Self::Close => "CLOSE",
                Self::Ping => "PING",
                Self::Pong => "PONG",
                Self::Error => "ERROR",
                Self::Event => "EVENT",
                Self::Auth => "AUTH",
                Self::AuthAck => "AUTH_ACK",
                Self::Kicked => "KICKED",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "UNSPECIFIED" => Some(Self::Unspecified),
                "CONNECT" => Some(Self::Connect),
                "CONNECT_ACK" => Some(Self::ConnectAck),
                "CLOSE" => Some(Self::Close),
                "PING" => Some(Self::Ping),
                "PONG" => Some(Self::Pong),
                "ERROR" => Some(Self::Error),
                "EVENT" => Some(Self::Event),
                "AUTH" => Some(Self::Auth),
                "AUTH_ACK" => Some(Self::AuthAck),
                "KICKED" => Some(Self::Kicked),
                _ => None,
            }
        }
    }
    /// 序列化格式(仅在 CONNECT/CONNECT_ACK 时使用)
    #[derive(serde::Serialize, serde::Deserialize)]
    #[serde(rename_all = "snake_case")]
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum SerializationFormat {
        /// Protobuf 序列化
        Protobuf = 0,
        /// JSON 序列化
        Json = 1,
    }
    impl SerializationFormat {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Protobuf => "PROTOBUF",
                Self::Json => "JSON",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "PROTOBUF" => Some(Self::Protobuf),
                "JSON" => Some(Self::Json),
                _ => None,
            }
        }
    }
}
/// ------------------------------------------------------------
/// 消息命令
/// ------------------------------------------------------------
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MessageCommand {
    #[prost(enumeration = "message_command::Type", tag = "1")]
    pub r#type: i32,
    /// 消息唯一ID
    #[prost(string, tag = "2")]
    pub message_id: ::prost::alloc::string::String,
    /// 消息内容
    #[prost(bytes = "vec", tag = "3")]
    pub payload: ::prost::alloc::vec::Vec<u8>,
    /// 元信息(统一为bytes类型)
    #[prost(map = "string, bytes", tag = "4")]
    pub metadata: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::vec::Vec<u8>,
    >,
    /// 序列号(可用于有序传输)
    #[prost(uint64, tag = "5")]
    pub seq: u64,
}
/// Nested message and enum types in `MessageCommand`.
pub mod message_command {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[serde(rename_all = "snake_case")]
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Type {
        /// 发送消息(需ACK)
        Send = 0,
        /// 确认消息
        Ack = 1,
        /// 普通数据传输(无需ACK,type已隐含need_ack)
        Data = 2,
    }
    impl Type {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::Send => "SEND",
                Self::Ack => "ACK",
                Self::Data => "DATA",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "SEND" => Some(Self::Send),
                "ACK" => Some(Self::Ack),
                "DATA" => Some(Self::Data),
                _ => None,
            }
        }
    }
}
/// ------------------------------------------------------------
/// 通知命令
/// ------------------------------------------------------------
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NotificationCommand {
    #[prost(enumeration = "notification_command::Type", tag = "1")]
    pub r#type: i32,
    /// 通知标题
    #[prost(string, tag = "2")]
    pub title: ::prost::alloc::string::String,
    /// 通知内容
    #[prost(bytes = "vec", tag = "3")]
    pub content: ::prost::alloc::vec::Vec<u8>,
    /// 附加信息(跳转参数等,统一为bytes类型)
    #[prost(map = "string, bytes", tag = "4")]
    pub metadata: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::vec::Vec<u8>,
    >,
}
/// Nested message and enum types in `NotificationCommand`.
pub mod notification_command {
    #[derive(serde::Serialize, serde::Deserialize)]
    #[serde(rename_all = "snake_case")]
    #[derive(
        Clone,
        Copy,
        Debug,
        PartialEq,
        Eq,
        Hash,
        PartialOrd,
        Ord,
        ::prost::Enumeration
    )]
    #[repr(i32)]
    pub enum Type {
        /// 系统通知(维护、更新等)
        System = 0,
        /// 广播消息
        Broadcast = 1,
        /// 警告提示
        Alert = 2,
        /// 用户状态变化
        User = 3,
        /// 连接事件(如重连)
        Connection = 4,
    }
    impl Type {
        /// String value of the enum field names used in the ProtoBuf definition.
        ///
        /// The values are not transformed in any way and thus are considered stable
        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
        pub fn as_str_name(&self) -> &'static str {
            match self {
                Self::System => "SYSTEM",
                Self::Broadcast => "BROADCAST",
                Self::Alert => "ALERT",
                Self::User => "USER",
                Self::Connection => "CONNECTION",
            }
        }
        /// Creates an enum from field names used in the ProtoBuf definition.
        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
            match value {
                "SYSTEM" => Some(Self::System),
                "BROADCAST" => Some(Self::Broadcast),
                "ALERT" => Some(Self::Alert),
                "USER" => Some(Self::User),
                "CONNECTION" => Some(Self::Connection),
                _ => None,
            }
        }
    }
}
/// ------------------------------------------------------------
/// 自定义命令
/// ------------------------------------------------------------
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CustomCommand {
    /// 自定义命令名
    #[prost(string, tag = "1")]
    pub name: ::prost::alloc::string::String,
    /// 自定义数据内容(JSON、protobuf等)
    #[prost(bytes = "vec", tag = "2")]
    pub data: ::prost::alloc::vec::Vec<u8>,
    /// 扩展元信息(统一为bytes类型)
    #[prost(map = "string, bytes", tag = "3")]
    pub metadata: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::vec::Vec<u8>,
    >,
}