participant.rs

 1use anyhow::{anyhow, Result};
 2use client::{proto, User};
 3use std::sync::Arc;
 4
 5#[derive(Copy, Clone, Debug, Eq, PartialEq)]
 6pub enum ParticipantLocation {
 7    Project { project_id: u64 },
 8    External,
 9}
10
11impl ParticipantLocation {
12    pub fn from_proto(location: Option<proto::ParticipantLocation>) -> Result<Self> {
13        match location.and_then(|l| l.variant) {
14            Some(proto::participant_location::Variant::Project(project)) => Ok(Self::Project {
15                project_id: project.id,
16            }),
17            Some(proto::participant_location::Variant::External(_)) => Ok(Self::External),
18            None => Err(anyhow!("participant location was not provided")),
19        }
20    }
21}
22
23#[derive(Clone, Debug)]
24pub struct RemoteParticipant {
25    pub user: Arc<User>,
26    pub project_ids: Vec<u64>,
27    pub location: ParticipantLocation,
28}