From 25665aa59495b5fbcedc85fb9e051ff0b8cb9d0e Mon Sep 17 00:00:00 2001 From: Saagar Jha Date: Mon, 7 Oct 2024 01:20:12 -0700 Subject: [PATCH] Unify UnxipStream apertures --- README.md | 2 +- unxip.swift | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8ee0fcd..cfb0e7d 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ import libunxip let data = DataReader(descriptor: STDIN_FILENO) var directories = 0 -for try await file in Unxip.makeStream(from: .xip(input: data), to: .files, input: data) where file.type == .directory { +for try await file in Unxip.makeStream(from: .xip(), to: .files(), input: data) where file.type == .directory { directories += 1 } print("This XIP contains \(directories) directories") diff --git a/unxip.swift b/unxip.swift index fb3a11c..7de647a 100644 --- a/unxip.swift +++ b/unxip.swift @@ -1319,23 +1319,19 @@ public enum Disk: StreamAperture { } public struct UnxipStream { - public static func xip(wrapping: @autoclosure () -> S) -> UnxipStream> where S.Element: RandomAccessCollection, S.Element.Element == UInt8 { - return .init() - } - - public static func xip(input: @autoclosure () -> DataReader) -> UnxipStream> where S.Element: RandomAccessCollection, S.Element.Element == UInt8 { - return .init() + public static func xip() -> UnxipStream> where S.Element: RandomAccessCollection, S.Element.Element == UInt8 { + .init() } - public static var chunks: UnxipStream { + public static func chunks() -> UnxipStream { .init() } - public static var files: UnxipStream { + public static func files() -> UnxipStream { .init() } - public static var disk: UnxipStream { + public static func disk() -> UnxipStream { .init() } } @@ -1589,7 +1585,7 @@ extension AsyncSequence where Element: Sendable, AsyncIterator: Sendable { } } - for try await file in Unxip.makeStream(from: .xip(wrapping: input), to: .disk, input: DataReader(data: input), nil, nil, .init(compress: options.compress, dryRun: options.dryRun)) { + for try await file in Unxip.makeStream(from: .xip(), to: .disk(), input: DataReader(data: input), nil, nil, .init(compress: options.compress, dryRun: options.dryRun)) { await statistics.note(file) if options.verbose { print(file.name)