kdeconnect_proto/packet/share.rs
1//! The Share plugin allows sharing files, text content and URLs.
2use serde::{Deserialize, Serialize};
3
4#[cfg(not(feature = "std"))]
5use alloc::string::String;
6
7/// This packet is an upload request.
8///
9/// <https://invent.kde.org/network/kdeconnect-meta/blob/master/protocol.md#kdeconnectsharerequest>
10#[derive(Serialize, Deserialize, Debug, Clone)]
11#[serde(rename_all = "camelCase")]
12pub struct ShareRequestPacket {
13 /// Name of the file being transferred. If the packet contains this field, it will be accompanied by payload transfer information.
14 #[serde(skip_serializing_if = "Option::is_none")]
15 #[serde(default)]
16 pub filename: Option<String>,
17
18 /// Creation time of the file being transferred as a UNIX epoch timestamp (ms).
19 #[serde(skip_serializing_if = "Option::is_none")]
20 #[serde(default)]
21 pub creation_time: Option<u64>,
22
23 /// Modification time of the file being transferred as a UNIX epoch timestamp (ms).
24 #[serde(skip_serializing_if = "Option::is_none")]
25 #[serde(default)]
26 pub last_modified: Option<u64>,
27
28 /// Whether a received file should be opened when the transfer completes.
29 #[serde(skip_serializing_if = "Option::is_none")]
30 #[serde(default)]
31 pub open: Option<bool>,
32
33 /// Number of files in a composite file transfer.
34 #[serde(skip_serializing_if = "Option::is_none")]
35 #[serde(default)]
36 pub number_of_files: Option<u64>,
37
38 /// Total size in bytes of a composite file transfer.
39 #[serde(skip_serializing_if = "Option::is_none")]
40 #[serde(default)]
41 pub total_payload_size: Option<u64>,
42
43 /// Text content being shared. The receiving device decides how to present to text to the user.
44 #[serde(skip_serializing_if = "Option::is_none")]
45 #[serde(default)]
46 pub text: Option<String>,
47
48 /// URL being shared. The receiving device will typically open the URL with the default handler for the URI scheme.
49 #[serde(skip_serializing_if = "Option::is_none")]
50 #[serde(default)]
51 pub url: Option<String>,
52}
53
54/// This packet is the metadata for a multi-file transfer. By convention it is sent in advance of
55/// the packets containing the payload, which will include the same fields, potentially with updated totals.
56///
57/// <https://invent.kde.org/network/kdeconnect-meta/blob/master/protocol.md#kdeconnectsharerequestupdate>
58#[derive(Serialize, Deserialize, Debug, Clone)]
59#[serde(rename_all = "camelCase")]
60pub struct ShareRequestUpdatePacket {
61 /// Number of files in a multi-file transfer.
62 #[serde(skip_serializing_if = "Option::is_none")]
63 #[serde(default)]
64 pub number_of_files: Option<u64>,
65
66 /// Total size in bytes of a multi-file transfer.
67 #[serde(skip_serializing_if = "Option::is_none")]
68 #[serde(default)]
69 pub total_payload_size: Option<u64>,
70}