// crate imports
// use super::message::Message;

// external imports
use serde::{Serialize, Deserialize};
use chrono::{DateTime, Utc};
use schemars::JsonSchema;

#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)]
pub struct Body {
    timestamp: DateTime<Utc>,
    content: String, // Consider making a buffer instead
//    #[serde(serialize_with = "Body::digest", deserialize_with = "Body::verify")]
    digest: String, // TODO: hmac-sha512
}
impl Body {
    pub fn new() -> Self {
        Self {
            timestamp: chrono::offset::Utc::now(),
            content: String::new(),
            digest: String::new(),
        }
    }
    pub fn timestamp(&self) -> &DateTime<Utc> {
        &self.timestamp
    }
    pub fn reset_timestamp(&mut self) {
        self.timestamp = chrono::offset::Utc::now()
    }
    pub fn content(&self) -> &str {
        &self.content
    }
    pub fn set_content(&mut self, content: &str) {
        self.content = content.to_string();
    }
    pub fn digest(&self) -> String {
        String::new() // TODO: hmac-sha512
    }
    pub fn verify(&self, digest: &str) -> std::result::Result<(), std::io::Error> {
        Ok(())
    }
}