use super::SnapshotKey;
use crate::private::{FileContent, encrypted::Encrypted};
use semver::Version;
use serde::{Deserialize, Serialize};
use skip_ratchet::Ratchet;
use std::collections::BTreeMap;
use wnfs_common::{Cid, HashOutput, Metadata};
use wnfs_nameaccumulator::{NameAccumulator, NameSegment};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[allow(clippy::large_enum_variant)]
pub(crate) enum PrivateNodeContentSerializable {
#[serde(rename = "wnfs/priv/file")]
File(PrivateFileContentSerializable),
#[serde(rename = "wnfs/priv/dir")]
Dir(PrivateDirectoryContentSerializable),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct PrivateFileContentSerializable {
pub version: Version,
pub header_cid: Cid,
pub previous: Vec<(usize, Encrypted<Cid>)>,
pub metadata: Metadata,
pub content: FileContent,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct PrivateDirectoryContentSerializable {
pub version: Version,
pub previous: Vec<(usize, Encrypted<Cid>)>,
pub header_cid: Cid,
pub metadata: Metadata,
pub entries: BTreeMap<String, PrivateRefSerializable>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub(crate) struct PrivateNodeHeaderSerializable {
pub inumber: NameSegment,
pub ratchet: Ratchet,
pub name: NameAccumulator,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct PrivateRefSerializable {
#[serde(with = "serde_byte_array")]
pub label: HashOutput,
pub snapshot_key: SnapshotKey,
#[serde(with = "serde_bytes")]
pub temporal_key: Vec<u8>,
pub content_cid: Cid,
}