SoftU2F/APDU/ErrorResponse.swift

32 строки
597 B
Swift
Исходник Обычный вид История

2017-01-27 01:14:27 +03:00
//
// ErrorResponse.swift
2017-07-19 20:54:47 +03:00
// SoftU2F
2017-01-27 01:14:27 +03:00
//
// Created by Benjamin P Toews on 1/26/17.
//
2017-02-07 21:34:05 +03:00
import Foundation
2017-01-27 01:14:27 +03:00
2017-02-08 03:25:44 +03:00
public struct ErrorResponse: RawConvertible {
public let body: Data
public let trailer: ResponseStatus
2017-01-27 01:14:27 +03:00
2017-02-07 21:34:05 +03:00
public init(status s: ResponseStatus) {
2017-02-08 03:25:44 +03:00
body = Data()
trailer = s
2017-01-27 01:14:27 +03:00
}
2017-02-08 03:25:44 +03:00
}
2017-01-27 01:14:27 +03:00
2017-02-08 03:25:44 +03:00
extension ErrorResponse: Response {
public init(body: Data, trailer: ResponseStatus) {
2017-02-08 03:25:44 +03:00
self.body = body
self.trailer = trailer
2017-01-27 01:14:27 +03:00
}
public func validateBody() throws {
2017-02-08 03:25:44 +03:00
if body.count != 0 {
throw ResponseError.BadSize
}
2017-01-27 02:13:09 +03:00
}
2017-01-27 01:14:27 +03:00
}