2022-09-23 13:05:32 +00:00
|
|
|
use anyhow::{anyhow, Result};
|
2022-10-03 14:09:49 +00:00
|
|
|
use client::{proto, User};
|
|
|
|
use std::sync::Arc;
|
2022-09-22 15:08:36 +00:00
|
|
|
|
2022-10-04 09:46:01 +00:00
|
|
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
2022-09-23 13:05:32 +00:00
|
|
|
pub enum ParticipantLocation {
|
|
|
|
Project { project_id: u64 },
|
2022-09-22 15:08:36 +00:00
|
|
|
External,
|
|
|
|
}
|
2022-09-19 16:01:34 +00:00
|
|
|
|
2022-09-23 13:05:32 +00:00
|
|
|
impl ParticipantLocation {
|
|
|
|
pub fn from_proto(location: Option<proto::ParticipantLocation>) -> Result<Self> {
|
|
|
|
match location.and_then(|l| l.variant) {
|
|
|
|
Some(proto::participant_location::Variant::Project(project)) => Ok(Self::Project {
|
|
|
|
project_id: project.id,
|
|
|
|
}),
|
|
|
|
Some(proto::participant_location::Variant::External(_)) => Ok(Self::External),
|
|
|
|
None => Err(anyhow!("participant location was not provided")),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-19 16:01:34 +00:00
|
|
|
pub struct RemoteParticipant {
|
2022-10-03 14:09:49 +00:00
|
|
|
pub user: Arc<User>,
|
|
|
|
pub project_ids: Vec<u64>,
|
2022-09-23 13:05:32 +00:00
|
|
|
pub location: ParticipantLocation,
|
2022-09-19 16:01:34 +00:00
|
|
|
}
|