-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kvsd_protocol): parse Message::Ping
- Loading branch information
Showing
7 changed files
with
129 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
pub(super) mod authenticate; | ||
mod authenticate; | ||
pub use authenticate::Authenticate; | ||
|
||
mod ping; | ||
pub use ping::Ping; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use crate::{ | ||
message::{MessageFrames, MessageType}, | ||
Time, | ||
}; | ||
|
||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct Ping { | ||
pub client_timestamp: Option<Time>, | ||
pub server_timestamp: Option<Time>, | ||
} | ||
|
||
impl Ping { | ||
pub fn new() -> Self { | ||
Self { | ||
client_timestamp: None, | ||
server_timestamp: None, | ||
} | ||
} | ||
} | ||
|
||
impl Default for Ping { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl From<Ping> for MessageFrames { | ||
fn from(ping: Ping) -> Self { | ||
let mut frames = MessageFrames::new(MessageType::Ping, 2); | ||
|
||
frames.push_time_or_null(ping.client_timestamp); | ||
frames.push_time_or_null(ping.server_timestamp); | ||
|
||
frames | ||
} | ||
} |