//! Secure note: just a multiline body, Zeroizing.

use serde::{Deserialize, Serialize};
use zeroize::Zeroizing;

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct SecureNoteCore {
    pub body: Zeroizing<String>,
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn secure_note_round_trips() {
        let note = SecureNoteCore { body: Zeroizing::new("a multi\nline note".into()) };
        let json = serde_json::to_string(&note).unwrap();
        let parsed: SecureNoteCore = serde_json::from_str(&json).unwrap();
        assert_eq!(parsed.body.as_str(), "a multi\nline note");
    }

    #[test]
    fn empty_body_round_trips() {
        let note = SecureNoteCore::default();
        let json = serde_json::to_string(&note).unwrap();
        let parsed: SecureNoteCore = serde_json::from_str(&json).unwrap();
        assert!(parsed.body.is_empty());
    }
}
