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.
/// Frame 表示统一的消息结构
/// 包含必要的元数据和实际的命令
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Frame {
    /// 实际命令
    #[prost(message, optional, tag = "1")]
    pub command: ::core::option::Option<super::commands::Command>,
    /// 消息唯一标识(用于消息确认和去重)
    #[prost(string, tag = "2")]
    pub message_id: ::prost::alloc::string::String,
    /// 消息的可靠性等级(尽力而为、至少一次、精确一次、有序)
    #[prost(enumeration = "Reliability", tag = "3")]
    pub reliability: i32,
    /// 消息创建时间戳(自 Unix 纪元起的毫秒数)
    #[prost(uint64, tag = "4")]
    pub timestamp: u64,
    /// 元数据键值对(用于附加信息:session_id、priority、compression、encrypted等)
    #[prost(map = "string, bytes", tag = "5")]
    pub metadata: ::std::collections::HashMap<
        ::prost::alloc::string::String,
        ::prost::alloc::vec::Vec<u8>,
    >,
}
/// Reliability 定义消息的投递保证等级
#[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 Reliability {
    /// 尽力而为投递(不保证可靠性)
    BestEffort = 0,
    /// 至少一次投递(可能重复,但不丢失)
    AtLeastOnce = 1,
    /// 精确一次投递(确保消息仅投递一次)
    ExactlyOnce = 2,
    /// 有序投递(消息按顺序投递)
    Ordered = 3,
}
impl Reliability {
    /// 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::BestEffort => "BEST_EFFORT",
            Self::AtLeastOnce => "AT_LEAST_ONCE",
            Self::ExactlyOnce => "EXACTLY_ONCE",
            Self::Ordered => "ORDERED",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "BEST_EFFORT" => Some(Self::BestEffort),
            "AT_LEAST_ONCE" => Some(Self::AtLeastOnce),
            "EXACTLY_ONCE" => Some(Self::ExactlyOnce),
            "ORDERED" => Some(Self::Ordered),
            _ => None,
        }
    }
}