ruma_client_api/dehydrated_device/
put_dehydrated_device.rs
1pub mod unstable {
6 use std::collections::BTreeMap;
11
12 use ruma_common::{
13 api::{request, response, Metadata},
14 encryption::{DeviceKeys, OneTimeKey},
15 metadata,
16 serde::Raw,
17 OwnedDeviceId, OwnedOneTimeKeyId,
18 };
19
20 use crate::dehydrated_device::DehydratedDeviceData;
21
22 const METADATA: Metadata = metadata! {
23 method: PUT,
24 rate_limited: false,
25 authentication: AccessToken,
26 history: {
27 unstable => "/_matrix/client/unstable/org.matrix.msc3814.v1/dehydrated_device",
28 }
29 };
30
31 #[request(error = crate::Error)]
33 pub struct Request {
34 pub device_id: OwnedDeviceId,
36
37 pub initial_device_display_name: Option<String>,
39
40 pub device_data: Raw<DehydratedDeviceData>,
43
44 pub device_keys: Raw<DeviceKeys>,
46
47 #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
49 pub one_time_keys: BTreeMap<OwnedOneTimeKeyId, Raw<OneTimeKey>>,
50
51 #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
53 pub fallback_keys: BTreeMap<OwnedOneTimeKeyId, Raw<OneTimeKey>>,
54 }
55
56 #[response(error = crate::Error)]
58 pub struct Response {
59 pub device_id: OwnedDeviceId,
61 }
62
63 impl Request {
64 pub fn new(
66 device_id: OwnedDeviceId,
67 device_data: Raw<DehydratedDeviceData>,
68 device_keys: Raw<DeviceKeys>,
69 ) -> Self {
70 Self {
71 device_id,
72 device_data,
73 device_keys,
74 initial_device_display_name: None,
75 one_time_keys: Default::default(),
76 fallback_keys: Default::default(),
77 }
78 }
79 }
80
81 impl Response {
82 pub fn new(device_id: OwnedDeviceId) -> Self {
84 Self { device_id }
85 }
86 }
87}