toe_beans/v4/message/options/
time.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
5pub struct TimeOption(u32);
6
7impl TimeOption {
8 pub fn new(seconds: u32) -> Self {
10 Self(seconds)
11 }
12
13 #[inline]
15 pub fn extend_into(&self, bytes: &mut Vec<u8>, tag: u8) {
16 bytes.push(tag); bytes.push(4); bytes.extend_from_slice(&self.0.to_be_bytes()); }
20}
21
22impl From<&[u8]> for TimeOption {
23 fn from(value: &[u8]) -> Self {
24 let bytes: [u8; 4] = value.try_into().unwrap();
25 Self(u32::from_be_bytes(bytes))
26 }
27}