aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/WireGuardResult.swift
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard/WireGuardResult.swift')
-rw-r--r--WireGuard/WireGuard/WireGuardResult.swift28
1 files changed, 28 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/WireGuardResult.swift b/WireGuard/WireGuard/WireGuardResult.swift
new file mode 100644
index 0000000..93fc4c2
--- /dev/null
+++ b/WireGuard/WireGuard/WireGuardResult.swift
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: MIT
+// Copyright © 2018 WireGuard LLC. All Rights Reserved.
+
+enum WireGuardResult<T> {
+ case success(T)
+ case failure(WireGuardAppError)
+
+ var value: T? {
+ switch (self) {
+ case .success(let v): return v
+ case .failure(_): return nil
+ }
+ }
+
+ var error: WireGuardAppError? {
+ switch (self) {
+ case .success(_): return nil
+ case .failure(let e): return e
+ }
+ }
+
+ var isSuccess: Bool {
+ switch (self) {
+ case .success(_): return true
+ case .failure(_): return false
+ }
+ }
+}