feat(crypto): Add toString methods on identifier objects.

This commit is contained in:
Ivan Enderlin
2022-05-17 13:32:59 +02:00
parent f01cfe42b4
commit 8161360852

View File

@@ -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].