Skip to content

Commit

Permalink
fix: support collab type from number trait
Browse files Browse the repository at this point in the history
  • Loading branch information
qinluhe committed Apr 13, 2024
1 parent 352c551 commit 6d20dd4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions collab-entity/src/collab_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub enum CollabType {
Empty = 6,
}


impl CollabType {
pub fn value(&self) -> i32 {
self.clone() as i32
Expand Down Expand Up @@ -117,6 +118,26 @@ impl Display for CollabType {
}
}

trait FromNumber {
fn from_number(n: i32) -> Self
where
Self: Sized;
}

impl FromNumber for CollabType {
fn from_number(n: i32) -> CollabType {
match n {
0 => CollabType::Document,
1 => CollabType::Database,
2 => CollabType::WorkspaceDatabase,
3 => CollabType::Folder,
4 => CollabType::DatabaseRow,
5 => CollabType::UserAwareness,
_ => CollabType::Empty,
}
}
}

#[derive(Clone, Debug)]
pub struct CollabObject {
pub object_id: String,
Expand Down

0 comments on commit 6d20dd4

Please sign in to comment.