//! Protobuf message types for CAN sync API + peer-to-peer protocol. //! //! These match the types in CAN service's routes/sync.rs exactly. use prost::Message; // ── CAN Sync API messages (protobuf, same as CAN service) ─────────────── #[derive(Clone, PartialEq, Message)] pub struct HashListRequest {} #[derive(Clone, PartialEq, Message)] pub struct HashListResponse { #[prost(message, repeated, tag = "1")] pub assets: Vec, } #[derive(Clone, PartialEq, Message)] pub struct AssetDigest { #[prost(string, tag = "1")] pub hash: String, #[prost(int64, tag = "2")] pub timestamp: i64, #[prost(int64, tag = "3")] pub size: i64, #[prost(bool, tag = "4")] pub is_trashed: bool, } #[derive(Clone, PartialEq, Message)] pub struct PullRequest { #[prost(string, repeated, tag = "1")] pub hashes: Vec, } #[derive(Clone, PartialEq, Message)] pub struct PullResponse { #[prost(message, repeated, tag = "1")] pub bundles: Vec, } #[derive(Clone, PartialEq, Message)] pub struct AssetBundle { #[prost(string, tag = "1")] pub hash: String, #[prost(int64, tag = "2")] pub timestamp: i64, #[prost(string, tag = "3")] pub mime_type: String, #[prost(string, optional, tag = "4")] pub application: Option, #[prost(string, optional, tag = "5")] pub user_identity: Option, #[prost(string, optional, tag = "6")] pub description: Option, #[prost(string, optional, tag = "7")] pub human_filename: Option, #[prost(string, optional, tag = "8")] pub human_path: Option, #[prost(bool, tag = "9")] pub is_trashed: bool, #[prost(int64, tag = "10")] pub size: i64, #[prost(string, repeated, tag = "11")] pub tags: Vec, #[prost(bytes = "vec", tag = "12")] pub content: Vec, } #[derive(Clone, PartialEq, Message)] pub struct PushRequest { #[prost(message, optional, tag = "1")] pub bundle: Option, } #[derive(Clone, PartialEq, Message)] pub struct PushResponse { #[prost(string, tag = "1")] pub hash: String, #[prost(bool, tag = "2")] pub already_existed: bool, } #[derive(Clone, PartialEq, Message)] pub struct MetaUpdateRequest { #[prost(string, tag = "1")] pub hash: String, #[prost(string, optional, tag = "2")] pub description: Option, #[prost(string, repeated, tag = "3")] pub tags: Vec, #[prost(bool, tag = "4")] pub is_trashed: bool, } #[derive(Clone, PartialEq, Message)] pub struct MetaUpdateResponse { #[prost(bool, tag = "1")] pub success: bool, } // ── Peer-to-peer messages (sent over QUIC streams between sync agents) ── /// Sent between peers during reconciliation: "here are all the hashes I have" #[derive(Clone, PartialEq, Message)] pub struct PeerHashSet { #[prost(message, repeated, tag = "1")] pub assets: Vec, } /// Request from peer: "please send me these assets" #[derive(Clone, PartialEq, Message)] pub struct PeerPullRequest { #[prost(string, repeated, tag = "1")] pub hashes: Vec, } /// A single asset being sent from one peer to another #[derive(Clone, PartialEq, Message)] pub struct PeerAssetTransfer { #[prost(message, optional, tag = "1")] pub bundle: Option, }