use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PingEvent {
#[serde(skip_serializing_if = "Option::is_none")]
pub seq: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<u64>,
}
impl PingEvent {
#[must_use]
pub const fn new() -> Self {
Self {
seq: None,
timestamp: None,
}
}
#[must_use]
pub const fn with_seq(seq: u64) -> Self {
Self {
seq: Some(seq),
timestamp: None,
}
}
#[must_use]
pub const fn with_timestamp(timestamp: u64) -> Self {
Self {
seq: None,
timestamp: Some(timestamp),
}
}
}
impl Default for PingEvent {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PongEvent {
#[serde(skip_serializing_if = "Option::is_none")]
pub seq: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<u64>,
}
impl PongEvent {
#[must_use]
pub const fn new() -> Self {
Self {
seq: None,
timestamp: None,
}
}
#[must_use]
pub const fn with_seq(seq: u64) -> Self {
Self {
seq: Some(seq),
timestamp: None,
}
}
#[must_use]
pub const fn from_ping(ping: &PingEvent) -> Self {
Self {
seq: ping.seq,
timestamp: ping.timestamp,
}
}
}
impl Default for PongEvent {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
#[path = "health_tests.rs"]
mod tests;