File tree Expand file tree Collapse file tree 1 file changed +1
-26
lines changed
Sources/ClientRuntime/PrimitiveTypeExtensions Expand file tree Collapse file tree 1 file changed +1
-26
lines changed Original file line number Diff line number Diff line change 44 */
55
66import struct Foundation. Data
7- import class Foundation. InputStream
87
98public typealias Data = Foundation . Data
109
11- extension Data {
12- init ( reading inputStream: InputStream ) throws {
13- self . init ( )
14- inputStream. open ( )
15- defer {
16- inputStream. close ( )
17- }
18-
19- let bufferSize = 1024
20- let buffer = UnsafeMutablePointer< UInt8> . allocate( capacity: bufferSize)
21- defer {
22- buffer. deallocate ( )
23- }
24- while inputStream. hasBytesAvailable {
25- let read = inputStream. read ( buffer, maxLength: bufferSize)
26- if read < 0 {
27- throw inputStream. streamError!
28- } else if read == 0 {
29- // EOF
30- break
31- }
32- self . append ( buffer, count: read)
33- }
34- }
35- }
10+ // Add extensions here as necessary
You can’t perform that action at this time.
0 commit comments