feat(ffi): additional HumanQrGrantLoginError enum values

This commit is contained in:
Hugh Nimmo-Smith
2026-02-17 08:36:00 +00:00
committed by Damir Jelić
parent 2cfd53e64d
commit 3cf4faec83
2 changed files with 54 additions and 1 deletions

View File

@@ -31,6 +31,16 @@ All notable changes to this project will be documented in this file.
### Features
- Add `HumanQrGrantLoginError::ConnectionInsecure` for errors establishing the secure channel
([#6141](https://github.com/matrix-org/matrix-rust-sdk/pull/6141)
- Add `HumanQrGrantLoginError::Expired` for when a timeout is encountered during the grant
([#6141](https://github.com/matrix-org/matrix-rust-sdk/pull/6141)
- Add `HumanQrGrantLoginError::Cancelled` for when the grant is cancelled
([#6141](https://github.com/matrix-org/matrix-rust-sdk/pull/6141)
- Add `HumanQrGrantLoginError::OtherDeviceAlreadySignedIn` for when the other device is already signed in
([#6141](https://github.com/matrix-org/matrix-rust-sdk/pull/6141)
- Add `HumanQrGrantLoginError::DeviceNotFound` for when the requested device was not returned by the homeserver
([#6141](https://github.com/matrix-org/matrix-rust-sdk/pull/6141)
- Add `RoomInfo::is_low_priority` for getting the room's `m.lowpriority` tag state
([#6183](https://github.com/matrix-org/matrix-rust-sdk/pull/6183))
- Add `Client::subscribe_to_duplicate_key_upload_errors` for listening to duplicate key

View File

@@ -405,14 +405,36 @@ pub enum HumanQrGrantLoginError {
/// An unknown error has happened.
#[error("An unknown error has happened.")]
Unknown(String),
/// The requested device was not returned by the homeserver.
#[error("The requested device was not returned by the homeserver.")]
DeviceNotFound,
/// The other device is already signed in and so does not need to sign in.
#[error("The other device is already signed and so does not need to sign in.")]
OtherDeviceAlreadySignedIn,
/// The sign in was cancelled.
#[error("The sign in was cancelled.")]
Cancelled,
/// The sign in was not completed in the required time.
#[error("The sign in was not completed in the required time.")]
Expired,
/// A secure connection could not have been established between the two
/// devices.
#[error("A secure connection could not have been established between the two devices.")]
ConnectionInsecure,
}
impl From<qrcode::QRCodeGrantLoginError> for HumanQrGrantLoginError {
fn from(value: qrcode::QRCodeGrantLoginError) -> Self {
use qrcode::QRCodeGrantLoginError;
use qrcode::{QRCodeGrantLoginError, SecureChannelError};
match value {
QRCodeGrantLoginError::DeviceIDAlreadyInUse => Self::DeviceIDAlreadyInUse,
QRCodeGrantLoginError::DeviceNotFound => Self::DeviceNotFound,
QRCodeGrantLoginError::InvalidCheckCode => Self::InvalidCheckCode,
QRCodeGrantLoginError::UnableToCreateDevice => Self::UnableToCreateDevice,
QRCodeGrantLoginError::UnsupportedProtocol(protocol) => {
@@ -422,7 +444,28 @@ impl From<qrcode::QRCodeGrantLoginError> for HumanQrGrantLoginError {
Self::MissingSecretsBackup(error.map_or("other".to_owned(), |e| e.to_string()))
}
QRCodeGrantLoginError::NotFound => Self::NotFound,
QRCodeGrantLoginError::SecureChannel(e) => match e {
SecureChannelError::Utf8(_)
| SecureChannelError::MessageDecode(_)
| SecureChannelError::Json(_)
| SecureChannelError::RendezvousChannel(_)
| SecureChannelError::UnsupportedQrCodeType => Self::Unknown(e.to_string()),
SecureChannelError::SecureChannelMessage { .. }
| SecureChannelError::Ecies(_)
| SecureChannelError::InvalidCheckCode
| SecureChannelError::CannotReceiveCheckCode => Self::ConnectionInsecure,
SecureChannelError::InvalidIntent => Self::OtherDeviceAlreadySignedIn,
},
QRCodeGrantLoginError::UnexpectedMessage { .. } => Self::Unknown(value.to_string()),
QRCodeGrantLoginError::Unknown(string) => Self::Unknown(string),
QRCodeGrantLoginError::LoginFailure { reason, .. } => match reason {
LoginFailureReason::UnsupportedProtocol => Self::UnsupportedProtocol(
"Other device does not support any of our protocols".to_owned(),
),
LoginFailureReason::AuthorizationExpired => Self::Expired,
LoginFailureReason::UserCancelled => Self::Cancelled,
_ => Self::Unknown(reason.to_string()),
},
}
}
}