events: Move room::create::RoomType to ruma-common
This commit is contained in:
parent
d987b80c56
commit
557a595877
@ -7,9 +7,10 @@ pub mod v3 {
|
||||
|
||||
use assign::assign;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_common::room::RoomType;
|
||||
use ruma_events::{
|
||||
room::{
|
||||
create::{PreviousRoom, RoomCreateEventContent, RoomType},
|
||||
create::{PreviousRoom, RoomCreateEventContent},
|
||||
power_levels::RoomPowerLevelsEventContent,
|
||||
},
|
||||
AnyInitialStateEvent,
|
||||
|
@ -12,6 +12,7 @@ pub mod power_levels;
|
||||
pub mod presence;
|
||||
pub mod push;
|
||||
pub mod receipt;
|
||||
pub mod room;
|
||||
pub mod thirdparty;
|
||||
mod time;
|
||||
pub mod to_device;
|
||||
|
28
crates/ruma-common/src/room.rs
Normal file
28
crates/ruma-common/src/room.rs
Normal file
@ -0,0 +1,28 @@
|
||||
//! Common types for rooms.
|
||||
|
||||
use ruma_serde::StringEnum;
|
||||
|
||||
use crate::PrivOwnedStr;
|
||||
|
||||
/// An enum of possible room types.
|
||||
///
|
||||
/// This type can hold an arbitrary string. To check for room types 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 RoomType {
|
||||
/// Defines the room as a space.
|
||||
#[ruma_enum(rename = "m.space")]
|
||||
Space,
|
||||
|
||||
/// Defines the room as a custom type.
|
||||
#[doc(hidden)]
|
||||
_Custom(PrivOwnedStr),
|
||||
}
|
||||
|
||||
impl RoomType {
|
||||
/// Creates a string slice from this `RoomType`.
|
||||
pub fn as_str(&self) -> &str {
|
||||
self.as_ref()
|
||||
}
|
||||
}
|
@ -2,13 +2,11 @@
|
||||
//!
|
||||
//! [`m.room.create`]: https://spec.matrix.org/v1.2/client-server-api/#mroomcreate
|
||||
|
||||
use ruma_common::room::RoomType;
|
||||
use ruma_events_macros::EventContent;
|
||||
use ruma_identifiers::{EventId, RoomId, RoomVersionId, UserId};
|
||||
use ruma_serde::StringEnum;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::PrivOwnedStr;
|
||||
|
||||
/// The content of an `m.room.create` event.
|
||||
///
|
||||
/// This is the first event in a room and cannot be changed.
|
||||
@ -62,29 +60,6 @@ impl RoomCreateEventContent {
|
||||
}
|
||||
}
|
||||
|
||||
/// An enum of possible room types.
|
||||
///
|
||||
/// 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 RoomType {
|
||||
/// Defines the room as a space.
|
||||
#[ruma_enum(rename = "m.space")]
|
||||
Space,
|
||||
|
||||
/// Defines the room as a custom type.
|
||||
#[doc(hidden)]
|
||||
_Custom(PrivOwnedStr),
|
||||
}
|
||||
|
||||
impl RoomType {
|
||||
/// Creates a string slice from this `RoomType`.
|
||||
pub fn as_str(&self) -> &str {
|
||||
self.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
/// A reference to an old room replaced during a room version upgrade.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user