1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#![allow(unused_qualifications)]
use std::convert::TryFrom;
use serde::de::{self, Deserializer, Unexpected};
#[doc(inline)]
pub use self::{
client_secret::{ClientSecret, OwnedClientSecret},
crypto_algorithms::{
DeviceKeyAlgorithm, EventEncryptionAlgorithm, KeyDerivationAlgorithm, SigningKeyAlgorithm,
},
device_id::{DeviceId, OwnedDeviceId},
device_key_id::{DeviceKeyId, OwnedDeviceKeyId},
event_id::{EventId, OwnedEventId},
key_id::{
DeviceSigningKeyId, KeyId, OwnedDeviceSigningKeyId, OwnedKeyId, OwnedServerSigningKeyId,
OwnedSigningKeyId, ServerSigningKeyId, SigningKeyId,
},
key_name::{KeyName, OwnedKeyName},
matrix_uri::{MatrixToUri, MatrixUri},
mxc_uri::{MxcUri, OwnedMxcUri},
room_alias_id::{OwnedRoomAliasId, RoomAliasId},
room_id::{OwnedRoomId, RoomId},
room_name::{OwnedRoomName, RoomName},
room_or_room_alias_id::{OwnedRoomOrAliasId, RoomOrAliasId},
room_version_id::RoomVersionId,
server_name::{OwnedServerName, ServerName},
session_id::{OwnedSessionId, SessionId},
signatures::{DeviceSignatures, EntitySignatures, ServerSignatures, Signatures},
transaction_id::{OwnedTransactionId, TransactionId},
user_id::{OwnedUserId, UserId},
};
#[doc(inline)]
pub use ruma_identifiers_validation::error::Error as IdParseError;
pub mod matrix_uri;
pub mod user_id;
mod client_secret;
mod crypto_algorithms;
mod device_id;
mod device_key_id;
mod event_id;
mod key_id;
mod key_name;
mod mxc_uri;
mod room_alias_id;
mod room_id;
mod room_name;
mod room_or_room_alias_id;
mod room_version_id;
mod server_name;
mod session_id;
mod signatures;
mod transaction_id;
#[cfg(feature = "rand")]
fn generate_localpart(length: usize) -> Box<str> {
use rand::Rng as _;
rand::thread_rng()
.sample_iter(&rand::distributions::Alphanumeric)
.map(char::from)
.take(length)
.collect::<String>()
.into_boxed_str()
}
fn deserialize_id<'de, D, T>(deserializer: D, expected_str: &str) -> Result<T, D::Error>
where
D: Deserializer<'de>,
T: for<'a> TryFrom<&'a str>,
{
crate::serde::deserialize_cow_str(deserializer).and_then(|v| {
T::try_from(&v).map_err(|_| de::Error::invalid_value(Unexpected::Str(&v), &expected_str))
})
}
#[macro_export]
macro_rules! device_id {
($s:expr) => {
<&$crate::DeviceId as ::std::convert::From<_>>::from($s)
};
}
#[doc(hidden)]
pub mod _macros {
pub use ruma_macros::{
device_key_id, event_id, mxc_uri, room_alias_id, room_id, room_version_id, server_name,
server_signing_key_id, user_id,
};
}
#[macro_export]
macro_rules! device_key_id {
($s:literal) => {
$crate::_macros::device_key_id!($crate, $s)
};
}
#[macro_export]
macro_rules! event_id {
($s:literal) => {
$crate::_macros::event_id!($crate, $s)
};
}
#[macro_export]
macro_rules! room_alias_id {
($s:literal) => {
$crate::_macros::room_alias_id!($crate, $s)
};
}
#[macro_export]
macro_rules! room_id {
($s:literal) => {
$crate::_macros::room_id!($crate, $s)
};
}
#[macro_export]
macro_rules! room_version_id {
($s:literal) => {
$crate::_macros::room_version_id!($crate, $s)
};
}
#[macro_export]
macro_rules! server_signing_key_id {
($s:literal) => {
$crate::_macros::server_signing_key_id!($crate, $s)
};
}
#[macro_export]
macro_rules! server_name {
($s:literal) => {
$crate::_macros::server_name!($crate, $s)
};
}
#[macro_export]
macro_rules! mxc_uri {
($s:literal) => {
$crate::_macros::mxc_uri!($crate, $s)
};
}
#[macro_export]
macro_rules! user_id {
($s:literal) => {
$crate::_macros::user_id!($crate, $s)
};
}