feat: add codemp user to api

super stub but whatev
This commit is contained in:
əlemi 2024-08-08 21:55:21 +02:00
parent 0aa7690533
commit f14a8c40a5
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 37 additions and 1 deletions

View file

@ -13,7 +13,11 @@ pub mod change;
/// representation for an user's cursor /// representation for an user's cursor
pub mod cursor; pub mod cursor;
/// data structure for service users
pub mod user;
pub use controller::Controller; 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 user::User;

29
src/api/user.rs Normal file
View file

@ -0,0 +1,29 @@
//! # User
//!
//! data structures for our service users
use uuid::Uuid;
/// represents a service user
///
/// all users are identified uniquely with UUIDs
#[derive(Debug, Clone)]
pub struct User {
pub id: Uuid,
}
impl From<codemp_proto::common::Identity> for User {
fn from(value: codemp_proto::common::Identity) -> Self {
Self {
id: uuid::Uuid::parse_str(&value.id).expect("invalid uuid"),
}
}
}
impl From<User> for codemp_proto::common::Identity {
fn from(value: User) -> Self {
Self {
id: value.id.to_string(),
}
}
}

View file

@ -12,12 +12,15 @@ pub use crate::api::{
TextChange as CodempTextChange, TextChange as CodempTextChange,
Cursor as CodempCursor, Cursor as CodempCursor,
Op as CodempOp, Op as CodempOp,
User as CodempUser,
}; };
pub use crate::{ pub use crate::{
client::Client as CodempClient, client::Client as CodempClient,
workspace::Workspace as CodempWorkspace, workspace::Workspace as CodempWorkspace,
workspace::UserInfo as CodempUserInfo,
cursor::Controller as CodempCursorController, cursor::Controller as CodempCursorController,
buffer::Controller as CodempBufferController, buffer::Controller as CodempBufferController,
}; };
#[deprecated = "use CodempUser instead"]
pub use crate::api::user::User as CodempUserInfo;