holochain_integrity_types/x_salsa20_poly1305/
encrypted_data.rs

1use crate::x_salsa20_poly1305::nonce::XSalsa20Poly1305Nonce;
2
3#[derive(PartialEq, Eq, serde::Serialize, serde::Deserialize, Debug, Clone)]
4pub struct XSalsa20Poly1305EncryptedData {
5    nonce: XSalsa20Poly1305Nonce,
6    #[serde(with = "serde_bytes")]
7    encrypted_data: Vec<u8>,
8}
9
10impl XSalsa20Poly1305EncryptedData {
11    pub fn new(nonce: XSalsa20Poly1305Nonce, encrypted_data: Vec<u8>) -> Self {
12        Self {
13            nonce,
14            encrypted_data,
15        }
16    }
17
18    pub fn as_nonce_ref(&self) -> &XSalsa20Poly1305Nonce {
19        &self.nonce
20    }
21
22    pub fn as_encrypted_data_ref(&self) -> &[u8] {
23        &self.encrypted_data
24    }
25}