Explorar o código

Add ending input stream behavior

maxep %!s(int64=5) %!d(string=hai) anos
pai
achega
935be9263e
Modificáronse 2 ficheiros con 6 adicións e 0 borrados
  1. 2 0
      Sources/Binary/Input.swift
  2. 4 0
      Sources/Binary/TLV.swift

+ 2 - 0
Sources/Binary/Input.swift

@@ -28,6 +28,8 @@ public class Input {
         bytes.suffix(from: offset)
     }
 
+    public var hasBytesAvailable: Bool { stream.hasBytesAvailable }
+
     private let stream: InputStream
 
     public init(bytes: Bytes) {

+ 4 - 0
Sources/Binary/TLV.swift

@@ -31,6 +31,10 @@ public protocol TLVProtocol {
     var value: Value { get set }
 }
 
+public protocol Endable {
+    var isAtEnd: Bool { get }
+}
+
 public struct TLV<Type, Lenght>: TLVProtocol where Lenght: BinaryInteger {
 
     public let type: Type