Skip to content

Commit

Permalink
Fix error type naming issue (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
cobward authored Jan 17, 2025
1 parent 603f9c2 commit cf7f709
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 59 deletions.
108 changes: 54 additions & 54 deletions MobileSdkRs/Sources/MobileSdkRs/mobile_sdk_rs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8265,58 +8265,6 @@ extension DidMethod: Equatable, Hashable {}



public enum Error {



case General(String
)
}


public struct FfiConverterTypeError: FfiConverterRustBuffer {
typealias SwiftType = Error

public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Error {
let variant: Int32 = try readInt(&buf)
switch variant {




case 1: return .General(
try FfiConverterString.read(from: &buf)
)

default: throw UniffiInternalError.unexpectedEnumCase
}
}

public static func write(_ value: Error, into buf: inout [UInt8]) {
switch value {





case let .General(v1):
writeInt(&buf, Int32(1))
FfiConverterString.write(v1, into: &buf)

}
}
}


extension Error: Equatable, Hashable {}

extension Error: Foundation.LocalizedError {
public var errorDescription: String? {
String(reflecting: self)
}
}


public enum HttpClientError {


Expand Down Expand Up @@ -8936,6 +8884,58 @@ extension MDocItem: Equatable, Hashable {}



public enum MdlUtilError {



case General(String
)
}


public struct FfiConverterTypeMdlUtilError: FfiConverterRustBuffer {
typealias SwiftType = MdlUtilError

public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MdlUtilError {
let variant: Int32 = try readInt(&buf)
switch variant {




case 1: return .General(
try FfiConverterString.read(from: &buf)
)

default: throw UniffiInternalError.unexpectedEnumCase
}
}

public static func write(_ value: MdlUtilError, into buf: inout [UInt8]) {
switch value {





case let .General(v1):
writeInt(&buf, Int32(1))
FfiConverterString.write(v1, into: &buf)

}
}
}


extension MdlUtilError: Equatable, Hashable {}

extension MdlUtilError: Foundation.LocalizedError {
public var errorDescription: String? {
String(reflecting: self)
}
}


public enum MdocEncodingError {


Expand Down Expand Up @@ -12676,7 +12676,7 @@ public func generatePopPrepare(audience: String, nonce: String?, didMethod: DidM
* Generate a new test mDL with hardcoded values, using the supplied key as the DeviceKey.
*/
public func generateTestMdl(keyManager: KeyStore, keyAlias: KeyAlias)throws -> Mdoc {
return try FfiConverterTypeMdoc.lift(try rustCallWithError(FfiConverterTypeError.lift) {
return try FfiConverterTypeMdoc.lift(try rustCallWithError(FfiConverterTypeMdlUtilError.lift) {
uniffi_mobile_sdk_rs_fn_func_generate_test_mdl(
FfiConverterTypeKeyStore.lower(keyManager),
FfiConverterTypeKeyAlias.lower(keyAlias),$0
Expand Down Expand Up @@ -12909,7 +12909,7 @@ private var initializationResult: InitializationResult = {
if (uniffi_mobile_sdk_rs_checksum_func_generate_pop_prepare() != 54105) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mobile_sdk_rs_checksum_func_generate_test_mdl() != 58352) {
if (uniffi_mobile_sdk_rs_checksum_func_generate_test_mdl() != 22635) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_mobile_sdk_rs_checksum_func_handle_response() != 43961) {
Expand Down
10 changes: 5 additions & 5 deletions src/mdl/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ use x509_cert::{
use crate::crypto::{KeyAlias, KeyStore};

#[derive(Debug, uniffi::Error)]
pub enum Error {
pub enum MdlUtilError {
General(String),
}

impl From<anyhow::Error> for Error {
impl From<anyhow::Error> for MdlUtilError {
fn from(value: anyhow::Error) -> Self {
Self::General(format!("{value:#}"))
}
}

impl std::error::Error for Error {}
impl std::error::Error for MdlUtilError {}

impl fmt::Display for Error {
impl fmt::Display for MdlUtilError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let Self::General(cause) = self;
write!(f, "{}", cause)
Expand All @@ -69,7 +69,7 @@ impl fmt::Display for Error {
pub fn generate_test_mdl(
key_manager: Arc<dyn KeyStore>,
key_alias: KeyAlias,
) -> Result<crate::credential::mdoc::Mdoc, Error> {
) -> Result<crate::credential::mdoc::Mdoc, MdlUtilError> {
Ok(generate_test_mdl_inner(key_manager, key_alias)?)
}

Expand Down

0 comments on commit cf7f709

Please sign in to comment.