2019-01-05 17:37:34 +00:00
|
|
|
//
|
|
|
|
// NetworkResult.swift
|
|
|
|
// MasKit
|
|
|
|
//
|
|
|
|
// Created by Ben Chatelain on 1/5/19.
|
|
|
|
// Copyright © 2019 mas-cli. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
enum NetworkResult {
|
|
|
|
case success(Data)
|
|
|
|
case failure(Error)
|
|
|
|
}
|
|
|
|
|
|
|
|
extension NetworkResult: Equatable {
|
|
|
|
static func == (lhs: NetworkResult, rhs: NetworkResult) -> Bool {
|
|
|
|
switch (lhs, rhs) {
|
2019-01-30 06:15:24 +00:00
|
|
|
case let (.success(data1), .success(data2)):
|
2019-01-05 17:37:34 +00:00
|
|
|
return data1 == data2
|
|
|
|
|
2019-01-30 06:15:24 +00:00
|
|
|
case let (.failure(error1), .failure(error2)):
|
2019-01-05 17:37:34 +00:00
|
|
|
return error1.localizedDescription == error2.localizedDescription
|
|
|
|
|
|
|
|
// case (.none, .none):
|
|
|
|
// return true
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|