use std::fmt;
use std::sync::Arc;
#[derive(Debug, Clone, PartialEq)]
pub struct PclHeader {
pub seq: u32,
pub stamp: u64,
pub frame_id: String,
}
pub type HeaderPtr = Arc<PclHeader>;
pub type HeaderConstPtr = Arc<PclHeader>;
impl PclHeader {
pub fn new(_seq: u32, _stamp: u64, _frame_id: String) -> Self {
PclHeader {
seq: _seq,
stamp: _stamp,
frame_id: _frame_id,
}
}
pub fn new_auto() -> Self {
PclHeader {
seq: rand::random(),
stamp: std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_secs(),
frame_id: String::from(""),
}
}
}
impl fmt::Display for PclHeader {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"seq: {} stamp: {} frame_id: {}",
self.seq, self.stamp, self.frame_id
)
}
}