|
|
@ -118,6 +118,10 @@ impl ProtoEncode for ServerResponse { |
|
|
encoder.encode_u32(CODE_PARENT_MIN_SPEED)?;
|
|
|
encoder.encode_u32(CODE_PARENT_MIN_SPEED)?;
|
|
|
response.encode(encoder)?;
|
|
|
response.encode(encoder)?;
|
|
|
},
|
|
|
},
|
|
|
|
|
|
ServerResponse::ParentSpeedRatioResponse(ref response) => {
|
|
|
|
|
|
encoder.encode_u32(CODE_PARENT_SPEED_RATIO)?;
|
|
|
|
|
|
response.encode(encoder)?;
|
|
|
|
|
|
},
|
|
|
_ => {
|
|
|
_ => {
|
|
|
unimplemented!();
|
|
|
unimplemented!();
|
|
|
},
|
|
|
},
|
|
|
@ -146,6 +150,10 @@ impl ProtoDecode for ServerResponse { |
|
|
let response = ParentMinSpeedResponse::decode(decoder)?;
|
|
|
let response = ParentMinSpeedResponse::decode(decoder)?;
|
|
|
ServerResponse::ParentMinSpeedResponse(response)
|
|
|
ServerResponse::ParentMinSpeedResponse(response)
|
|
|
},
|
|
|
},
|
|
|
|
|
|
CODE_PARENT_SPEED_RATIO => {
|
|
|
|
|
|
let response = ParentSpeedRatioResponse::decode(decoder)?;
|
|
|
|
|
|
ServerResponse::ParentSpeedRatioResponse(response)
|
|
|
|
|
|
},
|
|
|
_ => {
|
|
|
_ => {
|
|
|
return Err(DecodeError::UnknownCodeError(code));
|
|
|
return Err(DecodeError::UnknownCodeError(code));
|
|
|
},
|
|
|
},
|
|
|
@ -395,6 +403,21 @@ impl ReadFromPacket for ParentSpeedRatioResponse { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl ProtoEncode for ParentSpeedRatioResponse {
|
|
|
|
|
|
fn encode(&self, encoder: &mut ProtoEncoder) -> Result<(), io::Error> {
|
|
|
|
|
|
encoder.encode_u32(self.value)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl ProtoDecode for ParentSpeedRatioResponse {
|
|
|
|
|
|
fn decode(decoder: &mut ProtoDecoder) -> Result<Self, DecodeError> {
|
|
|
|
|
|
let value = decoder.decode_u32()?;
|
|
|
|
|
|
Ok(Self {
|
|
|
|
|
|
value: value
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/*==============*
|
|
|
/*==============*
|
|
|
* PEER ADDRESS *
|
|
|
* PEER ADDRESS *
|
|
|
*==============*/
|
|
|
*==============*/
|
|
|
@ -857,4 +880,11 @@ mod tests { |
|
|
value: 1337,
|
|
|
value: 1337,
|
|
|
}))
|
|
|
}))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
fn roundtrip_parent_speed_ratio() {
|
|
|
|
|
|
roundtrip(ServerResponse::ParentSpeedRatioResponse(ParentSpeedRatioResponse {
|
|
|
|
|
|
value: 1337,
|
|
|
|
|
|
}))
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|