gameServer2/src/protocol/messages.rs
changeset 13796 59ea2403f62d
parent 13667 bfc2727daead
child 13798 4664da990556
equal deleted inserted replaced
13795:e335daaa77a9 13796:59ea2403f62d
   149     [$($part: expr),*] => {
   149     [$($part: expr),*] => {
   150         format!(concat!($(const_braces!($part)),*, "\n"), $($part),*);
   150         format!(concat!($(const_braces!($part)),*, "\n"), $($part),*);
   151     };
   151     };
   152 }
   152 }
   153 
   153 
       
   154 #[cfg(test)]
   154 macro_rules! several {
   155 macro_rules! several {
   155     [$part: expr] => { once($part) };
   156     [$part: expr] => { once($part) };
   156     [$part: expr, $($other: expr),*] => { once($part).chain(several![$($other),*]) };
   157     [$part: expr, $($other: expr),*] => { once($part).chain(several![$($other),*]) };
   157 }
   158 }
   158 
   159 
   159 impl HWProtocolMessage {
   160 impl HWProtocolMessage {
   160     /** Converts the message to a raw `String`, which can be sent over the network.
   161     /** Converts the message to a raw `String`, which can be sent over the network.
   161      *
   162      *
   162      * This is the inverse of the `message` parser.
   163      * This is the inverse of the `message` parser.
   163      */
   164      */
       
   165     #[cfg(test)]
   164     pub(crate) fn to_raw_protocol(&self) -> String {
   166     pub(crate) fn to_raw_protocol(&self) -> String {
   165         use self::HWProtocolMessage::*;
   167         use self::HWProtocolMessage::*;
   166         match self {
   168         match self {
   167             Ping => msg!["PING"],
   169             Ping => msg!["PING"],
   168             Pong => msg!["PONG"],
   170             Pong => msg!["PONG"],