1use anyhow::{anyhow, Result};
2use client::{proto, User};
3use gpui::WeakModelHandle;
4use project::Project;
5use std::sync::Arc;
6
7#[derive(Copy, Clone, Debug, Eq, PartialEq)]
8pub enum ParticipantLocation {
9 SharedProject { project_id: u64 },
10 UnsharedProject,
11 External,
12}
13
14impl ParticipantLocation {
15 pub fn from_proto(location: Option<proto::ParticipantLocation>) -> Result<Self> {
16 match location.and_then(|l| l.variant) {
17 Some(proto::participant_location::Variant::SharedProject(project)) => {
18 Ok(Self::SharedProject {
19 project_id: project.id,
20 })
21 }
22 Some(proto::participant_location::Variant::UnsharedProject(_)) => {
23 Ok(Self::UnsharedProject)
24 }
25 Some(proto::participant_location::Variant::External(_)) => Ok(Self::External),
26 None => Err(anyhow!("participant location was not provided")),
27 }
28 }
29}
30
31#[derive(Clone, Default)]
32pub struct LocalParticipant {
33 pub projects: Vec<proto::ParticipantProject>,
34 pub active_project: Option<WeakModelHandle<Project>>,
35}
36
37#[derive(Clone, Debug)]
38pub struct RemoteParticipant {
39 pub user: Arc<User>,
40 pub projects: Vec<proto::ParticipantProject>,
41 pub location: ParticipantLocation,
42}