Skip to content

Commit b5b2450

Browse files
pixlwavepoljar
authored andcommitted
ffi: Expose the QrCodeData server name.
1 parent fc071ba commit b5b2450

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bindings/matrix-sdk-ffi/src/client_builder.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ impl QrCodeData {
5757
pub fn from_bytes(bytes: Vec<u8>) -> Result<Arc<Self>, QrCodeDecodeError> {
5858
Ok(Self { inner: qrcode::QrCodeData::from_bytes(&bytes)? }.into())
5959
}
60+
61+
/// The server name contained within the scanned QR code data.
62+
///
63+
/// Note: This value is only present when scanning a QR code the belongs to
64+
/// a logged in client. The mode where the new client shows the QR code
65+
/// will return `None`.
66+
pub fn server_name(&self) -> Option<String> {
67+
match &self.inner.mode_data {
68+
QrCodeModeData::Reciprocate { server_name } => Some(server_name.to_owned()),
69+
QrCodeModeData::Login => None,
70+
}
71+
}
6072
}
6173

6274
/// Error type for the decoding of the [`QrCodeData`].

0 commit comments

Comments
 (0)