Browse Source

Implement Proto{De,En}code for ParentMinSpeedResponse.

wip
Titouan Rigoudy 7 years ago
parent
commit
142f50f530
1 changed files with 30 additions and 0 deletions
  1. +30
    -0
      src/proto/server/response.rs

+ 30
- 0
src/proto/server/response.rs View File

@ -118,6 +118,10 @@ impl ProtoEncode for ServerResponse {
encoder.encode_u32(CODE_PARENT_MIN_SPEED)?;
response.encode(encoder)?;
},
ServerResponse::ParentSpeedRatioResponse(ref response) => {
encoder.encode_u32(CODE_PARENT_SPEED_RATIO)?;
response.encode(encoder)?;
},
_ => {
unimplemented!();
},
@ -146,6 +150,10 @@ impl ProtoDecode for ServerResponse {
let response = ParentMinSpeedResponse::decode(decoder)?;
ServerResponse::ParentMinSpeedResponse(response)
},
CODE_PARENT_SPEED_RATIO => {
let response = ParentSpeedRatioResponse::decode(decoder)?;
ServerResponse::ParentSpeedRatioResponse(response)
},
_ => {
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 *
*==============*/
@ -857,4 +880,11 @@ mod tests {
value: 1337,
}))
}
#[test]
fn roundtrip_parent_speed_ratio() {
roundtrip(ServerResponse::ParentSpeedRatioResponse(ParentSpeedRatioResponse {
value: 1337,
}))
}
}

Loading…
Cancel
Save