kdeconnect-proto 0.1.0

A pure Rust modular implementation of the KDE Connect protocol
Documentation
//! The Contacts plugin allows devices to share contacts in vCard format.
use hashbrown::HashMap;
use serde::{Deserialize, Serialize};

#[cfg(not(feature = "std"))]
use alloc::{string::String, vec::Vec};

/// This packet is a request for a list of contact UIDs with vCard data.
///
/// <https://invent.kde.org/network/kdeconnect-meta/blob/master/protocol.md#kdeconnectcontactsrequest_vcards_by_uid>
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ContactsRequestVcardsByUid {
    /// A list of contact UIDs.
    pub uids: Vec<String>,
}

/// This packet is a list of contact UIDs with modification timestamps.
///
/// <https://invent.kde.org/network/kdeconnect-meta/blob/master/protocol.md#kdeconnectcontactsresponse_uids_timestamps>
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ContactsResponseUidsTimestamp {
    /// A list of contact UIDs. Each UID has a corresponding uid-timestamp pair in the
    /// [`ContactsResponseUidsTimestamp::timestamps`] field.
    pub uids: Vec<String>,

    /// A map containing the timestamp associated to a specific uid.
    #[serde(flatten)]
    pub timestamps: HashMap<String, u64>,
}

/// <https://invent.kde.org/network/kdeconnect-meta/blob/master/protocol.md#kdeconnectcontactsresponse_vcards>
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ContactsResponseVcards {
    /// A list of contact UIDs. Each UID has a corresponding uid-vcard pair in the
    /// [`ContactsResponseVcards::vcards`] field.
    pub uids: Vec<String>,

    /// A map containing the vcard data associated to a specific uid.
    #[serde(flatten)]
    pub vcards: HashMap<String, String>,
}