kdeconnect-proto 0.1.2

A pure Rust modular implementation of the KDE Connect protocol
Documentation
//! The SFTP plugin enables secure file sharing with SFTP.
use serde::{Deserialize, Serialize};

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

/// This packet contains SFTP login information.
///
/// <https://invent.kde.org/network/kdeconnect-meta/blob/master/protocol.md#kdeconnectsftp>
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct SftpPacket {
    /// An error message.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub error_message: Option<String>,

    /// The host address.
    pub ip: String,

    /// The host port.
    pub port: u16,

    /// The user. Currently always kdeconnect.
    pub user: String,

    /// The one-time password. :warning: Deprecated: use private key authentication via the TLS certificate.
    pub password: String,

    /// The base path of the remote server. This should generally only be used as a fallback if the multiPaths field is missing.
    pub path: String,

    /// An ordered list of paths for the remote server. Usually contains at least a 'root' directory and a path the the camera folder, but may contain additional paths to external storage devices.
    pub multi_paths: Vec<String>,

    /// An ordered list of names associated with the paths in multiPaths, in the same order.
    pub path_names: Vec<String>,
}

/// This packet is a request to start SFTP.
///
/// <https://invent.kde.org/network/kdeconnect-meta/blob/master/protocol.md#kdeconnectsftprequest>
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct SftpRequestPacket {
    /// A request for the remote device to prepare for SFTP and respond with a kdeconnect.sftp packet.
    start_browsing: bool,
}