events: Add as_str and as_bytes methods for EventType
This commit is contained in:
parent
0dcbec5fa7
commit
34243d49ba
@ -196,6 +196,18 @@ pub enum EventType {
|
|||||||
_Custom(String),
|
_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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ruma_serde::test::serde_json_eq;
|
use ruma_serde::test::serde_json_eq;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user