Add Status utility methods

This commit is contained in:
Joscha 2023-01-02 14:29:51 +01:00
parent 22e729289d
commit fab7ac52f2
2 changed files with 33 additions and 0 deletions

View file

@ -13,6 +13,9 @@ Procedure when bumping the version number:
## Unreleased ## Unreleased
### Added
- `Status` conversion utility methods
## v0.2.0 - 2022-12-10 ## v0.2.0 - 2022-12-10
### Added ### Added

View file

@ -216,6 +216,36 @@ pub enum Status {
Joined(Joined), Joined(Joined),
} }
impl Status {
pub fn into_joining(self) -> Option<Joining> {
match self {
Self::Joining(joining) => Some(joining),
Self::Joined(_) => None,
}
}
pub fn into_joined(self) -> Option<Joined> {
match self {
Self::Joining(_) => None,
Self::Joined(joined) => Some(joined),
}
}
pub fn joining(&self) -> Option<&Joining> {
match self {
Self::Joining(joining) => Some(joining),
Self::Joined(_) => None,
}
}
pub fn joined(&self) -> Option<&Joined> {
match self {
Self::Joining(_) => None,
Self::Joined(joined) => Some(joined),
}
}
}
struct State { struct State {
ws_tx: SplitSink<WsStream, tungstenite::Message>, ws_tx: SplitSink<WsStream, tungstenite::Message>,
last_id: usize, last_id: usize,