Add Status utility methods
This commit is contained in:
parent
22e729289d
commit
fab7ac52f2
2 changed files with 33 additions and 0 deletions
|
|
@ -13,6 +13,9 @@ Procedure when bumping the version number:
|
|||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
- `Status` conversion utility methods
|
||||
|
||||
## v0.2.0 - 2022-12-10
|
||||
|
||||
### Added
|
||||
|
|
|
|||
30
src/conn.rs
30
src/conn.rs
|
|
@ -216,6 +216,36 @@ pub enum Status {
|
|||
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 {
|
||||
ws_tx: SplitSink<WsStream, tungstenite::Message>,
|
||||
last_id: usize,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue