datagram_pinger/
lib.rs

1/*
2 * Copyright (c) Peter Bjorklund. All rights reserved. https://github.com/nimble-rust/nimble
3 * Licensed under the MIT License. See LICENSE in the project root for license information.
4 */
5use flood_rs::prelude::*;
6
7#[derive(Debug)]
8pub struct ClientTime(u16);
9
10impl ClientTime {
11    pub fn new(time: u16) -> Self {
12        Self(time)
13    }
14}
15
16impl Serialize for ClientTime {
17    fn serialize(&self, stream: &mut impl WriteOctetStream) -> std::io::Result<()>
18    where
19        Self: Sized,
20    {
21        stream.write_u16(self.0)
22    }
23}
24
25impl Deserialize for ClientTime {
26    fn deserialize(stream: &mut impl ReadOctetStream) -> std::io::Result<Self>
27    where
28        Self: Sized,
29    {
30        Ok(Self(stream.read_u16()?))
31    }
32}