use rmux_proto::{PaneTargetRef, WebShareListener, WebShareScope};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WebShareSummary {
pub id: String,
pub scope: WebShareScope,
pub spectator_url_redacted: Option<String>,
pub operator: bool,
pub spectator: bool,
pub active_spectators: u16,
pub active_operators: u16,
pub max_spectators: Option<u16>,
pub max_operators: Option<u16>,
pub expires_at_unix: Option<u64>,
pub kill_session_on_expire: bool,
}
impl WebShareSummary {
#[must_use]
pub fn pane_target(&self) -> Option<&PaneTargetRef> {
match &self.scope {
WebShareScope::Pane(target) => Some(target),
WebShareScope::Session(_) => None,
}
}
}
impl From<rmux_proto::WebShareSummary> for WebShareSummary {
fn from(value: rmux_proto::WebShareSummary) -> Self {
Self {
id: value.share_id,
scope: value.scope,
spectator_url_redacted: value.spectator_url,
operator: value.operator,
spectator: value.spectator,
active_spectators: value.active_spectators,
active_operators: value.active_operators,
max_spectators: value.max_spectators,
max_operators: value.max_operators,
expires_at_unix: value.expires_at_unix,
kill_session_on_expire: value.kill_session_on_expire,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WebConfigInfo {
pub host: String,
pub port: u16,
pub frontend_origin: String,
}
impl From<WebShareListener> for WebConfigInfo {
fn from(value: WebShareListener) -> Self {
Self {
host: value.host,
port: value.port,
frontend_origin: value.frontend_origin,
}
}
}