array_format/
timestamp.rs1use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
4
5#[repr(transparent)]
10#[derive(
11 Copy,
12 Clone,
13 Debug,
14 Default,
15 PartialEq,
16 Eq,
17 PartialOrd,
18 Ord,
19 Hash,
20 FromBytes,
21 IntoBytes,
22 KnownLayout,
23 Immutable,
24)]
25pub struct TimestampNs(pub i64);
26
27impl TimestampNs {
28 pub const fn new(nanos: i64) -> Self {
30 Self(nanos)
31 }
32
33 pub const fn nanos(self) -> i64 {
35 self.0
36 }
37}
38
39impl From<i64> for TimestampNs {
40 fn from(v: i64) -> Self {
41 Self(v)
42 }
43}
44
45impl From<TimestampNs> for i64 {
46 fn from(v: TimestampNs) -> i64 {
47 v.0
48 }
49}