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
31
32
33
34
35
36
37
38
39
40
41
42
/*! Offline struct
*/

use super::*;

/** Offline is a struct that holds nothing.

This packet is used to notify that a friend is being deleted.
Though the friend is deleted, because of conference, Tox client
may try to connect to the friend, this message prevent this friend to
be shown as Online.

*/
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Offline;

impl FromBytes for Offline {
    named!(from_bytes<Offline>, do_parse!(
        tag!("\x19") >>
        (Offline)
    ));
}

impl ToBytes for Offline {
    fn to_bytes<'a>(&self, buf: (&'a mut [u8], usize)) -> Result<(&'a mut [u8], usize), GenError> {
        do_gen!(buf,
            gen_be_u8!(0x19)
        )
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    encode_decode_test!(
        tox_crypto::crypto_init().unwrap(),
        offline_encode_decode,
        Offline
    );

}