diff --git a/crates/matrix-sdk-crypto/src/js/identifiers.rs b/crates/matrix-sdk-crypto/src/js/identifiers.rs index efc782202..7623b54a7 100644 --- a/crates/matrix-sdk-crypto/src/js/identifiers.rs +++ b/crates/matrix-sdk-crypto/src/js/identifiers.rs @@ -40,6 +40,12 @@ impl UserId { pub fn is_historical(&self) -> bool { self.inner.is_historical() } + + /// Return the user ID as a string. + #[wasm_bindgen(js_name = "toString")] + pub fn to_string(&self) -> String { + self.inner.as_str().to_owned() + } } /// A Matrix key ID. @@ -59,6 +65,12 @@ impl DeviceId { pub fn new(id: &str) -> DeviceId { Self { inner: id.into() } } + + /// Return the device ID as a string. + #[wasm_bindgen(js_name = "toString")] + pub fn to_string(&self) -> String { + self.inner.as_str().to_owned() + } } /// A Matrix [room ID]. @@ -88,6 +100,12 @@ impl RoomId { pub fn server_name(&self) -> ServerName { ServerName { inner: self.inner.server_name().to_owned() } } + + /// Return the device ID as a string. + #[wasm_bindgen(js_name = "toString")] + pub fn to_string(&self) -> String { + self.inner.as_str().to_owned() + } } /// A Matrix-spec compliant [server name].