blob: c4f09ccdbe755e834bc1e2c3d809caf21759d7b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
use crate::error::ProtocolError;
use crate::primitive::{Variant, VariantMap};
use crate::HandshakeSerialize;
/// ClientLoginReject is received after the client failed to login
/// It contains an error message as String
#[derive(Debug, Clone)]
pub struct ClientLoginReject {
pub error: String,
}
impl HandshakeSerialize for ClientLoginReject {
fn serialize(&self) -> Result<Vec<u8>, ProtocolError> {
let mut values: VariantMap = VariantMap::with_capacity(1);
values.insert(
"MsgType".to_string(),
Variant::String("ClientLoginReject".to_string()),
);
values.insert("ErrorString".to_string(), Variant::String(self.error.clone()));
HandshakeSerialize::serialize(&values)
}
}
impl From<VariantMap> for ClientLoginReject {
fn from(mut input: VariantMap) -> Self {
ClientLoginReject {
error: input.remove("ErrorString").unwrap().try_into().unwrap(),
}
}
}
|