toe_beans/v4/message/options/
time_offset.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
10pub struct TimeOffset(i32);
11
12impl TimeOffset {
13 pub fn new(seconds: i32) -> Self {
15 Self(seconds)
16 }
17
18 #[inline]
20 pub fn extend_into(&self, bytes: &mut Vec<u8>, tag: u8) {
21 bytes.push(tag); bytes.push(4); bytes.extend_from_slice(&self.0.to_be_bytes()); }
25}
26
27impl From<&[u8]> for TimeOffset {
28 fn from(value: &[u8]) -> Self {
29 let bytes: [u8; 4] = value.try_into().unwrap();
30 Self(i32::from_be_bytes(bytes))
31 }
32}