aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/WireGuardResult.swift
blob: e326f0c3e262f82241931a721ec3c4ea49f41ca3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// SPDX-License-Identifier: MIT
// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved.

enum WireGuardResult<T> {
    case success(_ value: T)
    case failure(_ error: WireGuardAppError)

    var value: T? {
        switch self {
        case .success(let value): return value
        case .failure: return nil
        }
    }

    var error: WireGuardAppError? {
        switch self {
        case .success: return nil
        case .failure(let error): return error
        }
    }

    var isSuccess: Bool {
        switch self {
        case .success: return true
        case .failure: return false
        }
    }
}