nimble_protocol_header/
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::{Deserialize, ReadOctetStream, Serialize, WriteOctetStream};
6
7#[derive(Debug)]
8pub struct ClientTime(u16);
9
10impl ClientTime {
11    pub fn new(time: u16) -> Self {
12        Self(time)
13    }
14
15    pub fn inner(&self) -> u16 {
16        self.0
17    }
18}
19
20impl Serialize for ClientTime {
21    fn serialize(&self, stream: &mut impl WriteOctetStream) -> std::io::Result<()>
22    where
23        Self: Sized,
24    {
25        stream.write_u16(self.0)
26    }
27}
28
29impl Deserialize for ClientTime {
30    fn deserialize(stream: &mut impl ReadOctetStream) -> std::io::Result<Self>
31    where
32        Self: Sized,
33    {
34        Ok(Self(stream.read_u16()?))
35    }
36}