#[non_exhaustive]pub struct RoomInfo {
pub id: RoomId,
pub kind: RoomKind,
pub key: Option<String>,
pub name: Option<String>,
pub member_count: Option<u32>,
pub max_members: Option<u32>,
pub peer: Option<UserId>,
}Expand description
A room.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: RoomIdThe id.
kind: RoomKindWhat kind of room.
key: Option<String>The key of a public room.
name: Option<String>A display name.
member_count: Option<u32>The number of members connected right now, if the server shares it.
max_members: Option<u32>The member cap, if any.
peer: Option<UserId>For a direct-message room: the other member.
Implementations§
Source§impl RoomInfo
impl RoomInfo
Sourcepub fn new(id: RoomId, kind: RoomKind) -> Self
pub fn new(id: RoomId, kind: RoomKind) -> Self
A room with no key, name or counts.
Examples found in repository?
examples/print_frames.rs (line 30)
23fn main() {
24 let now = UnixMillis(1_790_000_000_000);
25 println!("WebSocket");
26 println!("{:<22} {}", "auth (client)", WsAuth::new("example-access-token").to_message());
27 show("auth.ok", &WsServerFrame::AuthOk(Some(WsAuthOk::new(UserId(42)))));
28 show("auth.failed", &WsServerFrame::AuthFailed(ApiError::new(codes::TOKEN_EXPIRED, "the token expired")));
29 show("request chat.join", &WsRequestFrame::call(1, JoinRoom::new("world")));
30 show("answer", &WsResponseFrame::ok(1, RoomInfo::new(RoomId(12), RoomKind::Room).with_key("world")));
31 show("request chat.send", &WsRequestFrame::call(2, SendMessage::new(RoomId(12), "hello")));
32 show("answer", &WsResponseFrame::ok(2, SendAck::new(MessageId(981), now)));
33 show("refused", &WsResponseFrame::<()>::error(3, ApiError::new(codes::NOT_A_MEMBER, "join the room first")));
34 show("push chat.message", &WsPushFrame::push(ChatMessage::new(MessageId(981), RoomId(12), UserId(42), "hello", now).with_sender_name("Ada")));
35 let codes: Vec<String> = CloseCode::ALL.iter().map(|c| format!("{c}{}", if c.is_permanent() { " (permanent)" } else { "" })).collect();
36 println!("{:<22} {}", "close codes", codes.join(", "));
37
38 println!();
39 println!("HTTP");
40 show("POST login", &LoginRequest::new("ada@example.com", "example password"));
41 let tokens = TokenPair::new(
42 AccessToken::new("example-access"),
43 now.saturating_add_millis(3_600_000),
44 RefreshToken::new("example-refresh"),
45 now.saturating_add_millis(30 * 86_400_000),
46 );
47 show(" → 200", &AuthSession::new(Account::new(UserId(42), now).with_email("ada@example.com", true), tokens));
48 show("PUT storage object", &PutObject::new(serde_json::json!({"level": 3})).if_version(ObjectVersion(2)));
49 show(" → 409", &ErrorBody::new(ApiError::new(codes::VERSION_CONFLICT, "the object changed").with_details(serde_json::json!({"current_version": 3}))));
50}Sourcepub fn with_key(self, key: impl Into<String>) -> Self
pub fn with_key(self, key: impl Into<String>) -> Self
The same room with this key.
Examples found in repository?
examples/print_frames.rs (line 30)
23fn main() {
24 let now = UnixMillis(1_790_000_000_000);
25 println!("WebSocket");
26 println!("{:<22} {}", "auth (client)", WsAuth::new("example-access-token").to_message());
27 show("auth.ok", &WsServerFrame::AuthOk(Some(WsAuthOk::new(UserId(42)))));
28 show("auth.failed", &WsServerFrame::AuthFailed(ApiError::new(codes::TOKEN_EXPIRED, "the token expired")));
29 show("request chat.join", &WsRequestFrame::call(1, JoinRoom::new("world")));
30 show("answer", &WsResponseFrame::ok(1, RoomInfo::new(RoomId(12), RoomKind::Room).with_key("world")));
31 show("request chat.send", &WsRequestFrame::call(2, SendMessage::new(RoomId(12), "hello")));
32 show("answer", &WsResponseFrame::ok(2, SendAck::new(MessageId(981), now)));
33 show("refused", &WsResponseFrame::<()>::error(3, ApiError::new(codes::NOT_A_MEMBER, "join the room first")));
34 show("push chat.message", &WsPushFrame::push(ChatMessage::new(MessageId(981), RoomId(12), UserId(42), "hello", now).with_sender_name("Ada")));
35 let codes: Vec<String> = CloseCode::ALL.iter().map(|c| format!("{c}{}", if c.is_permanent() { " (permanent)" } else { "" })).collect();
36 println!("{:<22} {}", "close codes", codes.join(", "));
37
38 println!();
39 println!("HTTP");
40 show("POST login", &LoginRequest::new("ada@example.com", "example password"));
41 let tokens = TokenPair::new(
42 AccessToken::new("example-access"),
43 now.saturating_add_millis(3_600_000),
44 RefreshToken::new("example-refresh"),
45 now.saturating_add_millis(30 * 86_400_000),
46 );
47 show(" → 200", &AuthSession::new(Account::new(UserId(42), now).with_email("ada@example.com", true), tokens));
48 show("PUT storage object", &PutObject::new(serde_json::json!({"level": 3})).if_version(ObjectVersion(2)));
49 show(" → 409", &ErrorBody::new(ApiError::new(codes::VERSION_CONFLICT, "the object changed").with_details(serde_json::json!({"current_version": 3}))));
50}Trait Implementations§
Source§impl<'de> Deserialize<'de> for RoomInfo
impl<'de> Deserialize<'de> for RoomInfo
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for RoomInfo
impl StructuralPartialEq for RoomInfo
Auto Trait Implementations§
impl Freeze for RoomInfo
impl RefUnwindSafe for RoomInfo
impl Send for RoomInfo
impl Sync for RoomInfo
impl Unpin for RoomInfo
impl UnsafeUnpin for RoomInfo
impl UnwindSafe for RoomInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.