federation/push: Make all pub enums non_exhaustive

This commit is contained in:
Devin Ragotzy 2021-06-29 19:22:28 -04:00 committed by Jonas Platte
parent c55dab7122
commit 1489b5e1f1
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
2 changed files with 22 additions and 0 deletions

View File

@ -69,7 +69,11 @@ impl Response {
}
/// Profile fields to specify in query.
///
/// This type can hold an arbitrary string. To check for formats that are not available as a
/// documented variant here, use its string representation, obtained through `.as_str()`.
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[non_exhaustive]
pub enum ProfileField {
/// Display name of the user.
#[ruma_enum(rename = "displayname")]
@ -82,3 +86,10 @@ pub enum ProfileField {
#[doc(hidden)]
_Custom(String),
}
impl ProfileField {
/// Creates a string slice from this `ProfileField`.
pub fn as_str(&self) -> &str {
self.as_ref()
}
}

View File

@ -136,8 +136,12 @@ impl<'a> Notification<'a> {
///
/// This may be used by push gateways to deliver less time-sensitive
/// notifications in a way that will preserve battery power on mobile devices.
///
/// This type can hold an arbitrary string. To check for formats that are not available as a
/// documented variant here, use its string representation, obtained through `.as_str()`.
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")]
#[non_exhaustive]
pub enum NotificationPriority {
/// A high priority notification
High,
@ -149,6 +153,13 @@ pub enum NotificationPriority {
_Custom(String),
}
impl NotificationPriority {
/// Creates a string slice from this `NotificationPriority`.
pub fn as_str(&self) -> &str {
self.as_ref()
}
}
impl Default for NotificationPriority {
fn default() -> Self {
Self::High