增加命令

This commit is contained in:
lubeilin
2023-01-04 22:09:59 +08:00
parent e37b4d718b
commit d4f941d4e7
9 changed files with 119 additions and 51 deletions
+18
View File
@@ -70,6 +70,7 @@ pub struct PongPacket<B> {
buffer: B,
}
impl<B: AsRef<[u8]>> PingPacket<B> {
pub fn new(buffer: B) -> Result<PingPacket<B>> {
let len = buffer.as_ref().len();
@@ -98,6 +99,15 @@ impl<B: AsRef<[u8]> + AsMut<[u8]>> PingPacket<B> {
}
}
impl<B: AsRef<[u8]>> fmt::Debug for PingPacket<B> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("PingPacket")
.field("time", &self.time())
.field("epoch", &self.epoch())
.finish()
}
}
impl<B: AsRef<[u8]>> PongPacket<B> {
pub fn new(buffer: B) -> Result<PongPacket<B>> {
let len = buffer.as_ref().len();
@@ -120,6 +130,14 @@ impl<B: AsRef<[u8]> + AsMut<[u8]>> PongPacket<B> {
}
}
impl<B: AsRef<[u8]>> fmt::Debug for PongPacket<B> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("PongPacket")
.field("time", &self.time())
.finish()
}
}
pub type TurnPongPacket<B> = TurnPingPacket<B>;
/// 探测目标延迟