Open MattKiazyk opened 12 months ago
Ah, that's an oversight, thanks for identifying this. With that said I think the route I want to take here is to make lockstepSplit
available on AsyncSequence
(I assume that's why you want to erase it?) I eventually want to the entire API exposed as some AsyncSequence
when typed throws lands, I'm just using AsyncThrowingStream
as a stopgap to avoid exposing internal stream types to clients.
So my ultimate goal was to use the libunxip inside Xcodes - but not having to deal with all the async stream stuff for the time being. Previously was using the CLI, where I could just pass in a single file and unxip would do everything.
So I was working on a Unxip.unxip(input: URL) async throws
inside of the library so that, if somebody wanted, could use the library with a single source.
If you just need a one-shot decompression, you should be good with this:
let handle = try FileHandle(forReadingFrom: input)
let data = DataReader.data(descriptor: handle.fileDescriptor)
for try await _ in Unxip.makeStream(from: .xip(input: data), to: .disk, input: data) {
}
If you just need a one-shot decompression, you should be good with this:
let handle = try FileHandle(forReadingFrom: input) let data = DataReader.data(descriptor: handle.fileDescriptor) for try await _ in Unxip.makeStream(from: .xip(input: data), to: .disk, input: data) { }
I could be way off but if i'm understanding all the code correctly, this isn't currently possible because UnxipStream
requires a AsyncSequence
which Datareader only produces a AsyncThrowingStream
Cannot convert value of type 'AsyncThrowingStream<[UInt8], any Error>' to expected argument type 'DataReader<S>'
That'll teach me for writing this from memory. Use let data = DataReader(descriptor: handle.fileDescriptor)
instead
When using
AsyncThrowingStream
similar to how the CLI works, I get errors with the following code:returns
Cannot convert value of type 'AsyncThrowingStream<[UInt8], any Error>' to expected argument type '() async throws -> Element?'