2018-12-06 11:00:11 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2023-02-14 15:10:32 +00:00
|
|
|
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
|
2018-12-06 11:00:11 +00:00
|
|
|
|
|
|
|
enum WireGuardResult<T> {
|
2018-12-12 17:40:57 +00:00
|
|
|
case success(_ value: T)
|
|
|
|
case failure(_ error: WireGuardAppError)
|
2018-12-06 11:00:11 +00:00
|
|
|
|
|
|
|
var value: T? {
|
2018-12-12 18:28:27 +00:00
|
|
|
switch self {
|
2018-12-12 17:40:57 +00:00
|
|
|
case .success(let value): return value
|
|
|
|
case .failure: return nil
|
2018-12-06 11:00:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var error: WireGuardAppError? {
|
2018-12-12 18:28:27 +00:00
|
|
|
switch self {
|
2018-12-12 17:40:57 +00:00
|
|
|
case .success: return nil
|
|
|
|
case .failure(let error): return error
|
2018-12-06 11:00:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var isSuccess: Bool {
|
2018-12-12 18:28:27 +00:00
|
|
|
switch self {
|
2018-12-12 17:40:57 +00:00
|
|
|
case .success: return true
|
|
|
|
case .failure: return false
|
2018-12-06 11:00:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|