identifiers: Add owned_* ID construction macros
This commit is contained in:
parent
00e619daa2
commit
a8670e7fdf
@ -95,6 +95,14 @@ macro_rules! device_id {
|
||||
};
|
||||
}
|
||||
|
||||
/// Shorthand for `OwnedDeviceId::from`.
|
||||
#[macro_export]
|
||||
macro_rules! owned_device_id {
|
||||
($s:expr) => {
|
||||
<$crate::OwnedDeviceId as ::std::convert::From<_>>::from($s)
|
||||
};
|
||||
}
|
||||
|
||||
// A plain re-export shows up in rustdoc despite doc(hidden). Use a module instead.
|
||||
// Bug report: https://github.com/rust-lang/rust/issues/83939
|
||||
#[doc(hidden)]
|
||||
@ -113,6 +121,14 @@ macro_rules! device_key_id {
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`OwnedDeviceKeyId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! owned_device_key_id {
|
||||
($s:literal) => {
|
||||
$crate::device_key_id!($s).to_owned()
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`EventId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! event_id {
|
||||
@ -121,6 +137,14 @@ macro_rules! event_id {
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`OwnedEventId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! owned_event_id {
|
||||
($s:literal) => {
|
||||
$crate::event_id($s).to_owned()
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`RoomAliasId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! room_alias_id {
|
||||
@ -129,6 +153,14 @@ macro_rules! room_alias_id {
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`OwnedRoomAliasId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! owned_room_alias_id {
|
||||
($s:literal) => {
|
||||
$crate::room_alias_id($s).to_owned()
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`RoomId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! room_id {
|
||||
@ -137,6 +169,14 @@ macro_rules! room_id {
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`OwnedRoomId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! owned_room_id {
|
||||
($s:literal) => {
|
||||
$crate::room_id($s).to_owned()
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`RoomVersionId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! room_version_id {
|
||||
@ -153,6 +193,14 @@ macro_rules! server_signing_key_id {
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`OwnedServerSigningKeyId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! owned_server_signing_key_id {
|
||||
($s:literal) => {
|
||||
$crate::server_signing_key_id($s).to_owned()
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`ServerName`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! server_name {
|
||||
@ -161,6 +209,14 @@ macro_rules! server_name {
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`OwnedServerName`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! owned_server_name {
|
||||
($s:literal) => {
|
||||
$crate::server_name($s).to_owned()
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`SessionId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! session_id {
|
||||
@ -174,6 +230,14 @@ macro_rules! session_id {
|
||||
}};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`OwnedSessionId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! owned_session_id {
|
||||
($s:literal) => {
|
||||
$crate::session_id($s).to_owned()
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`MxcUri`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! mxc_uri {
|
||||
@ -182,6 +246,14 @@ macro_rules! mxc_uri {
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`OwnedMxcUri`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! owned_mxc_uri {
|
||||
($s:literal) => {
|
||||
$crate::mxc_uri($s).to_owned()
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`UserId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! user_id {
|
||||
@ -189,3 +261,11 @@ macro_rules! user_id {
|
||||
$crate::_macros::user_id!($crate, $s)
|
||||
};
|
||||
}
|
||||
|
||||
/// Compile-time checked [`OwnedUserId`] construction.
|
||||
#[macro_export]
|
||||
macro_rules! owned_user_id {
|
||||
($s:literal) => {
|
||||
$crate::user_id($s).to_owned()
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user