diff --git a/proto/control-api/src/control/member.rs b/proto/control-api/src/control/member.rs index 272bbbb4..986cd881 100644 --- a/proto/control-api/src/control/member.rs +++ b/proto/control-api/src/control/member.rs @@ -3,7 +3,7 @@ use std::{ cmp::Ordering, collections::HashMap, - fmt, + fmt::Write as _, hash::{Hash, Hasher}, time::Duration, }; @@ -152,13 +152,21 @@ pub struct Sid { pub creds: Option, } -impl Display for Sid { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}/{}/{}", self.public_url, self.room_id, self.member_id)?; +impl Sid { + /// Exposes [Sid] to connect to a media server with a credentials. + pub fn expose(&self) -> String { + let mut sid = String::new(); + write!( + sid, + "{}/{}/{}", + self.public_url, self.room_id, self.member_id + ) + .expect("write to `String` never fails"); if let Some(plain) = &self.creds { - write!(f, "?token={}", plain.expose_str())?; + write!(sid, "?token={}", plain.expose_str()) + .expect("write to `String` never fails"); } - Ok(()) + sid } } diff --git a/proto/control-api/src/grpc/server.rs b/proto/control-api/src/grpc/server.rs index dcf2b84f..131516a4 100644 --- a/proto/control-api/src/grpc/server.rs +++ b/proto/control-api/src/grpc/server.rs @@ -45,7 +45,7 @@ where Ok(sids) => control_proto::CreateResponse { sid: sids .into_iter() - .map(|(id, sid)| (id.to_string(), sid.to_string())) + .map(|(id, sid)| (id.to_string(), sid.expose())) .collect(), error: None, }, @@ -129,7 +129,7 @@ where Ok(sids) => control_proto::CreateResponse { sid: sids .into_iter() - .map(|(id, sid)| (id.to_string(), sid.to_string())) + .map(|(id, sid)| (id.to_string(), sid.expose())) .collect(), error: None, },