events: Add as_str and as_bytes methods for EventType

This commit is contained in:
Jonas Platte 2021-04-05 21:49:50 +02:00
parent 0dcbec5fa7
commit 34243d49ba
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -196,6 +196,18 @@ pub enum EventType {
_Custom(String),
}
impl EventType {
/// Creates a string slice from this `EventType`.
pub fn as_str(&self) -> &str {
self.as_ref()
}
/// Creates a byte slice from this `EventType`.
pub fn as_bytes(&self) -> &[u8] {
self.as_str().as_bytes()
}
}
#[cfg(test)]
mod tests {
use ruma_serde::test::serde_json_eq;