|
@@ -22,7 +22,7 @@ public protocol Updatable {
|
|
/// - parameter bytes: Bytes to process.
|
|
/// - parameter bytes: Bytes to process.
|
|
/// - parameter isLast: Indicate if given chunk is the last one. No more updates after this call.
|
|
/// - parameter isLast: Indicate if given chunk is the last one. No more updates after this call.
|
|
/// - returns: Processed data or empty array.
|
|
/// - returns: Processed data or empty array.
|
|
- mutating func update<T: Collection>(withBytes bytes: T, isLast: Bool) throws -> Array<UInt8> where T.Iterator.Element == UInt8
|
|
|
|
|
|
+ mutating func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool) throws -> Array<UInt8>
|
|
|
|
|
|
/// Update given bytes in chunks.
|
|
/// Update given bytes in chunks.
|
|
///
|
|
///
|
|
@@ -31,30 +31,30 @@ public protocol Updatable {
|
|
/// - isLast: Indicate if given chunk is the last one. No more updates after this call.
|
|
/// - isLast: Indicate if given chunk is the last one. No more updates after this call.
|
|
/// - output: Resulting bytes callback.
|
|
/// - output: Resulting bytes callback.
|
|
/// - Returns: Processed data or empty array.
|
|
/// - Returns: Processed data or empty array.
|
|
- mutating func update<T: Collection>(withBytes bytes: T, isLast: Bool, output: (_ bytes: Array<UInt8>) -> Void) throws where T.Iterator.Element == UInt8
|
|
|
|
|
|
+ mutating func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool, output: (_ bytes: Array<UInt8>) -> Void) throws
|
|
|
|
|
|
/// Finish updates. This may apply padding.
|
|
/// Finish updates. This may apply padding.
|
|
/// - parameter bytes: Bytes to process
|
|
/// - parameter bytes: Bytes to process
|
|
/// - returns: Processed data.
|
|
/// - returns: Processed data.
|
|
- mutating func finish<T: Collection>(withBytes bytes: T) throws -> Array<UInt8> where T.Iterator.Element == UInt8
|
|
|
|
|
|
+ mutating func finish(withBytes bytes: ArraySlice<UInt8>) throws -> Array<UInt8>
|
|
|
|
|
|
/// Finish updates. This may apply padding.
|
|
/// Finish updates. This may apply padding.
|
|
/// - parameter bytes: Bytes to process
|
|
/// - parameter bytes: Bytes to process
|
|
/// - parameter output: Resulting data
|
|
/// - parameter output: Resulting data
|
|
/// - returns: Processed data.
|
|
/// - returns: Processed data.
|
|
- mutating func finish<T: Collection>(withBytes bytes: T, output: (_ bytes: Array<UInt8>) -> Void) throws where T.Iterator.Element == UInt8
|
|
|
|
|
|
+ mutating func finish(withBytes bytes: ArraySlice<UInt8>, output: (_ bytes: Array<UInt8>) -> Void) throws
|
|
}
|
|
}
|
|
|
|
|
|
extension Updatable {
|
|
extension Updatable {
|
|
|
|
|
|
- mutating public func update<T: Collection>(withBytes bytes: T, isLast: Bool = false, output: (_ bytes: Array<UInt8>) -> Void) throws where T.Iterator.Element == UInt8 {
|
|
|
|
|
|
+ mutating public func update(withBytes bytes: ArraySlice<UInt8>, isLast: Bool = false, output: (_ bytes: Array<UInt8>) -> Void) throws {
|
|
let processed = try self.update(withBytes: bytes, isLast: isLast)
|
|
let processed = try self.update(withBytes: bytes, isLast: isLast)
|
|
if (!processed.isEmpty) {
|
|
if (!processed.isEmpty) {
|
|
output(processed)
|
|
output(processed)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- mutating public func finish<T: Collection>(withBytes bytes: T) throws -> Array<UInt8> where T.Iterator.Element == UInt8 {
|
|
|
|
|
|
+ mutating public func finish(withBytes bytes: ArraySlice<UInt8>) throws -> Array<UInt8> {
|
|
return try self.update(withBytes: bytes, isLast: true)
|
|
return try self.update(withBytes: bytes, isLast: true)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -62,7 +62,7 @@ extension Updatable {
|
|
return try self.update(withBytes: [], isLast: true)
|
|
return try self.update(withBytes: [], isLast: true)
|
|
}
|
|
}
|
|
|
|
|
|
- mutating public func finish<T: Collection>(withBytes bytes: T, output: (_ bytes: Array<UInt8>) -> Void) throws where T.Iterator.Element == UInt8 {
|
|
|
|
|
|
+ mutating public func finish(withBytes bytes: ArraySlice<UInt8>, output: (_ bytes: Array<UInt8>) -> Void) throws {
|
|
let processed = try self.update(withBytes: bytes, isLast: true)
|
|
let processed = try self.update(withBytes: bytes, isLast: true)
|
|
if (!processed.isEmpty) {
|
|
if (!processed.isEmpty) {
|
|
output(processed)
|
|
output(processed)
|