mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 23:34:49 +01:00
feat: api struct for event
Co-authored-by: zaaarf <me@zaaarf.foo>
This commit is contained in:
parent
07dd964466
commit
a8b4eab445
2 changed files with 24 additions and 0 deletions
20
src/api/event.rs
Normal file
20
src/api/event.rs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
use codemp_proto::workspace::workspace_event::Event as WorkspaceEventInner;
|
||||||
|
|
||||||
|
pub enum Event {
|
||||||
|
FileTreeUpdated,
|
||||||
|
UserJoin(String),
|
||||||
|
UserLeave(String),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&WorkspaceEventInner> for Event {
|
||||||
|
fn from(event: &WorkspaceEventInner) -> Self {
|
||||||
|
match event {
|
||||||
|
WorkspaceEventInner::Join(e) => Self::UserJoin(e.user.id.clone()),
|
||||||
|
WorkspaceEventInner::Leave(e) => Self::UserLeave(e.user.id.clone()),
|
||||||
|
WorkspaceEventInner::Create(_)
|
||||||
|
| WorkspaceEventInner::Rename(_)
|
||||||
|
| WorkspaceEventInner::Delete(_)
|
||||||
|
=> Self::FileTreeUpdated,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,9 @@ pub mod change;
|
||||||
/// representation for an user's cursor
|
/// representation for an user's cursor
|
||||||
pub mod cursor;
|
pub mod cursor;
|
||||||
|
|
||||||
|
/// workspace events
|
||||||
|
pub mod event;
|
||||||
|
|
||||||
/// data structure for service users
|
/// data structure for service users
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
|
@ -20,4 +23,5 @@ pub use controller::Controller;
|
||||||
pub use change::TextChange;
|
pub use change::TextChange;
|
||||||
pub use change::Op;
|
pub use change::Op;
|
||||||
pub use cursor::Cursor;
|
pub use cursor::Cursor;
|
||||||
|
pub use event::Event;
|
||||||
pub use user::User;
|
pub use user::User;
|
||||||
|
|
Loading…
Reference in a new issue