Skip to content

Commit 67deefc

Browse files
committed
Fix code style
1 parent 2a0d2f7 commit 67deefc

24 files changed

+116
-103
lines changed

Sources/Stream/Library/BufferedStream/BufferedInputStream+StreamReader.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ extension BufferedInputStream: StreamReader {
1818

1919
public func peek<T>(
2020
count: Int,
21-
body: (UnsafeRawBufferPointer) throws -> T) async throws -> T
22-
{
21+
body: (UnsafeRawBufferPointer) throws -> T
22+
) async throws -> T {
2323
if count > buffered {
2424
try ensure(count: count)
2525
guard try await feed() && buffered >= count else {
@@ -59,8 +59,8 @@ extension BufferedInputStream {
5959
@inlinable
6060
public func read<T>(
6161
count: Int,
62-
body: (UnsafeRawBufferPointer) throws -> T) async throws -> T
63-
{
62+
body: (UnsafeRawBufferPointer) throws -> T
63+
) async throws -> T {
6464
if count > buffered {
6565
if count > allocated {
6666
try ensure(count: count)
@@ -83,8 +83,8 @@ extension BufferedInputStream {
8383
public func read<T>(
8484
mode: PredicateMode,
8585
while predicate: (UInt8) -> Bool,
86-
body: (UnsafeRawBufferPointer) throws -> T) async throws -> T
87-
{
86+
body: (UnsafeRawBufferPointer) throws -> T
87+
) async throws -> T {
8888
var read = 0
8989
while true {
9090
if read == buffered {
@@ -157,8 +157,8 @@ extension BufferedInputStream {
157157
@inlinable
158158
public func consume(
159159
mode: PredicateMode,
160-
while predicate: (UInt8) -> Bool) async throws
161-
{
160+
while predicate: (UInt8) -> Bool
161+
) async throws {
162162
while true {
163163
if buffered == 0 {
164164
guard try await feed() else {

Sources/Stream/Library/BufferedStream/BufferedInputStream.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public class BufferedInputStream<BaseStream: InputStream> {
8888
extension BufferedInputStream: InputStream {
8989
public func read(
9090
to buffer: UnsafeMutableRawPointer,
91-
byteCount: Int) async throws -> Int
92-
{
91+
byteCount: Int
92+
) async throws -> Int {
9393
switch buffered - byteCount {
9494

9595
// we have buffered more than requested
@@ -134,8 +134,8 @@ extension BufferedInputStream: InputStream {
134134
@inline(__always)
135135
private func flush(
136136
to buffer: UnsafeMutableRawPointer,
137-
byteCount: Int) -> Int
138-
{
137+
byteCount: Int
138+
) -> Int {
139139
assert(byteCount > buffered)
140140
buffer.copyMemory(from: readPosition, byteCount: buffered)
141141
let flushed = buffered

Sources/Stream/Library/BufferedStream/BufferedOutputStream.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public class BufferedOutputStream<BaseStream: OutputStream> {
3030
extension BufferedOutputStream: OutputStream {
3131
public func write(
3232
from buffer: UnsafeRawPointer,
33-
byteCount: Int) async throws -> Int
34-
{
33+
byteCount: Int
34+
) async throws -> Int {
3535
switch available - byteCount {
3636
// the bytes fit into the buffer
3737
case 0...:

Sources/Stream/Library/BufferedStream/BufferedStream+StreamReader.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ extension BufferedStream: StreamReader {
99

1010
public func peek<T>(
1111
count: Int,
12-
body: (UnsafeRawBufferPointer) throws -> T) async throws -> T
13-
{
12+
body: (UnsafeRawBufferPointer) throws -> T
13+
) async throws -> T {
1414
return try await inputStream.peek(count: count, body: body)
1515
}
1616

@@ -20,16 +20,16 @@ extension BufferedStream: StreamReader {
2020

2121
public func read<T>(
2222
count: Int,
23-
body: (UnsafeRawBufferPointer) throws -> T) async throws -> T
24-
{
23+
body: (UnsafeRawBufferPointer) throws -> T
24+
) async throws -> T {
2525
return try await inputStream.read(count: count, body: body)
2626
}
2727

2828
public func read<T>(
2929
mode: PredicateMode,
3030
while predicate: (UInt8) -> Bool,
31-
body: (UnsafeRawBufferPointer) throws -> T) async throws -> T
32-
{
31+
body: (UnsafeRawBufferPointer) throws -> T
32+
) async throws -> T {
3333
return try await inputStream.read(
3434
mode: mode, while: predicate, body: body)
3535
}
@@ -44,8 +44,8 @@ extension BufferedStream: StreamReader {
4444

4545
public func consume(
4646
mode: PredicateMode,
47-
while predicate: (UInt8) -> Bool) async throws
48-
{
47+
while predicate: (UInt8) -> Bool
48+
) async throws {
4949
try await inputStream.consume(mode: mode, while: predicate)
5050
}
5151
}

Sources/Stream/Library/ByteArrayStream/ByteArrayInputStream+StreamReader.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ extension ByteArrayInputStream: StreamReader {
2222

2323
public func peek<T>(
2424
count: Int,
25-
body: (UnsafeRawBufferPointer) throws -> T) throws -> T
26-
{
25+
body: (UnsafeRawBufferPointer) throws -> T
26+
) throws -> T {
2727
try ensure(count: count)
2828
return try bytes[position..<position+count].withUnsafeBytes(body)
2929
}
@@ -49,8 +49,8 @@ extension ByteArrayInputStream: StreamReader {
4949

5050
public func read<T>(
5151
count: Int,
52-
body: (UnsafeRawBufferPointer) throws -> T) throws -> T
53-
{
52+
body: (UnsafeRawBufferPointer) throws -> T
53+
) throws -> T {
5454
try ensure(count: count)
5555
let slice = bytes[position..<position+count]
5656
advance(by: count)
@@ -62,8 +62,8 @@ extension ByteArrayInputStream: StreamReader {
6262
public func read<T>(
6363
mode: PredicateMode,
6464
while predicate: (UInt8) -> Bool,
65-
body: (UnsafeRawBufferPointer) throws -> T) throws -> T
66-
{
65+
body: (UnsafeRawBufferPointer) throws -> T
66+
) throws -> T {
6767
var read = 0
6868
while true {
6969
if read == buffered {
@@ -98,8 +98,8 @@ extension ByteArrayInputStream: StreamReader {
9898

9999
public func consume(
100100
mode: PredicateMode,
101-
while predicate: (UInt8) -> Bool) throws
102-
{
101+
while predicate: (UInt8) -> Bool
102+
) throws {
103103
while true {
104104
if position == bytes.count {
105105
if mode == .untilEnd { break }

Sources/Stream/Library/ByteArrayStream/ByteArrayInputStream.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public class ByteArrayInputStream: InputStream {
1414
@inline(__always)
1515
public func read(
1616
to pointer: UnsafeMutableRawPointer,
17-
byteCount: Int) throws -> Int
18-
{
17+
byteCount: Int
18+
) throws -> Int {
1919
let count = min(bytes.count - position, byteCount)
2020
let buffer = UnsafeMutableRawBufferPointer(start: pointer, count: count)
2121
buffer.copyBytes(from: bytes[position..<position + count])

Sources/Stream/Library/ByteArrayStream/ByteArrayOutputStream.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public class ByteArrayOutputStream: OutputStream {
1111
@inline(__always)
1212
public func write(
1313
from buffer: UnsafeRawPointer,
14-
byteCount: Int) -> Int
15-
{
14+
byteCount: Int
15+
) -> Int {
1616
bytes.append(contentsOf: UnsafeRawBufferPointer(
1717
start: buffer,
1818
count: byteCount))

Sources/Stream/Library/MemoryStream/MemoryStream.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public final class MemoryStream: Stream, Seekable {
9191

9292
public func read(
9393
to buffer: UnsafeMutableRawPointer,
94-
byteCount: Int) throws -> Int
95-
{
94+
byteCount: Int
95+
) throws -> Int {
9696
let bytes = read(byteCount)
9797
guard bytes.count > 0 else {
9898
return 0
@@ -103,8 +103,8 @@ public final class MemoryStream: Stream, Seekable {
103103

104104
public func write(
105105
from buffer: UnsafeRawPointer,
106-
byteCount: Int) throws -> Int
107-
{
106+
byteCount: Int
107+
) throws -> Int {
108108
guard byteCount > 0 else {
109109
return 0
110110
}

Sources/Stream/Library/UnsafeRawStream/UnsafeRawStream+StreamReader.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ extension UnsafeRawInputStream: StreamReader {
3030

3131
public func peek<T>(
3232
count: Int,
33-
body: (UnsafeRawBufferPointer) throws -> T) throws -> T
34-
{
33+
body: (UnsafeRawBufferPointer) throws -> T
34+
) throws -> T {
3535
try ensure(count: count)
3636
let slice = bytes[position..<position+count]
3737
return try body(UnsafeRawBufferPointer(rebasing: slice))
@@ -57,8 +57,8 @@ extension UnsafeRawInputStream: StreamReader {
5757

5858
public func read<T>(
5959
count: Int,
60-
body: (UnsafeRawBufferPointer) throws -> T) throws -> T
61-
{
60+
body: (UnsafeRawBufferPointer) throws -> T
61+
) throws -> T {
6262
try ensure(count: count)
6363
let slice = self.bytes[position..<position+count]
6464
advance(by: count)
@@ -69,8 +69,8 @@ extension UnsafeRawInputStream: StreamReader {
6969
public func read<T>(
7070
mode: PredicateMode,
7171
while predicate: (UInt8) -> Bool,
72-
body: (UnsafeRawBufferPointer) throws -> T) throws -> T
73-
{
72+
body: (UnsafeRawBufferPointer) throws -> T
73+
) throws -> T {
7474
var read = 0
7575
while true {
7676
if read == buffered {
@@ -103,8 +103,8 @@ extension UnsafeRawInputStream: StreamReader {
103103

104104
public func consume(
105105
mode: PredicateMode,
106-
while predicate: (UInt8) -> Bool) throws
107-
{
106+
while predicate: (UInt8) -> Bool
107+
) throws {
108108
while true {
109109
if position == bytes.count {
110110
if mode == .untilEnd { break }

Sources/Stream/StreamReader+AllowedBytes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ extension StreamReader {
3131
@inline(__always)
3232
public func read<T>(
3333
allowedBytes: AllowedBytes,
34-
body: (UnsafeRawBufferPointer) throws -> T) async throws -> T
35-
{
34+
body: (UnsafeRawBufferPointer) throws -> T
35+
) async throws -> T {
3636
let buffer = allowedBytes.buffer
3737
return try await read(
3838
mode: .untilEnd,

Sources/Stream/StreamReader.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ extension StreamReader {
4040
@inline(__always)
4141
public func read<T>(
4242
until byte: UInt8,
43-
body: (UnsafeRawBufferPointer) throws -> T) async throws -> T
44-
{
43+
body: (UnsafeRawBufferPointer) throws -> T
44+
) async throws -> T {
4545
return try await read(
4646
mode: .strict,
4747
while: { $0 != byte },
@@ -50,8 +50,8 @@ extension StreamReader {
5050

5151
@inline(__always)
5252
public func readUntilEnd<T>(
53-
body: (UnsafeRawBufferPointer) throws -> T) async throws -> T
54-
{
53+
body: (UnsafeRawBufferPointer) throws -> T
54+
) async throws -> T {
5555
return try await read(
5656
mode: .untilEnd,
5757
while: { _ in true },
@@ -97,8 +97,8 @@ extension StreamReader {
9797
@inline(__always)
9898
public func read<T>(
9999
while predicate: (UInt8) -> Bool,
100-
body: (UnsafeRawBufferPointer) throws -> T) async throws -> T
101-
{
100+
body: (UnsafeRawBufferPointer) throws -> T
101+
) async throws -> T {
102102
return try await read(mode: .untilEnd, while: predicate, body: body)
103103
}
104104

@@ -123,8 +123,8 @@ extension StreamReader {
123123
@inlinable
124124
public func read(
125125
mode: PredicateMode = .untilEnd,
126-
while predicate: (UInt8) -> Bool) async throws -> [UInt8]
127-
{
126+
while predicate: (UInt8) -> Bool
127+
) async throws -> [UInt8] {
128128
return try await read(mode: mode, while: predicate, body: [UInt8].init)
129129
}
130130
}

Sources/Stream/SubStreamReader.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ extension StreamReader {
1313
public func withSubStreamReader<Size: FixedWidthInteger, Result>(
1414
sizedBy type: Size.Type,
1515
includingHeader: Bool = false,
16-
body: (SubStreamReader) async throws -> Result) async throws -> Result
17-
{
16+
body: (SubStreamReader) async throws -> Result
17+
) async throws -> Result {
1818
let length = includingHeader
1919
? Int(try await read(type)) - MemoryLayout<Size>.size
2020
: Int(try await read(type))
@@ -23,8 +23,8 @@ extension StreamReader {
2323

2424
public func withSubStreamReader<Result>(
2525
limitedBy limit: Int,
26-
body: (SubStreamReader) async throws -> Result) async throws -> Result
27-
{
26+
body: (SubStreamReader) async throws -> Result
27+
) async throws -> Result {
2828
// FIXME: [Concurrency] optimize
2929
let bytes = try await read(count: limit)
3030
let stream = ByteArrayInputStream(bytes)

Sources/Stream/SubStreamWriter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ extension StreamWriter {
1212
public func withSubStreamWriter<Size: FixedWidthInteger>(
1313
sizedBy type: Size.Type,
1414
includingHeader: Bool = false,
15-
task: (SubStreamWriter) async throws -> Void) async throws
16-
{
15+
task: (SubStreamWriter) async throws -> Void
16+
) async throws {
1717
let output = ByteArrayOutputStream()
1818
try await task(output)
1919
let sizeHeader = includingHeader

Sources/Stream/UnsafeRawBufferInitializable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ extension StreamReader {
3333
public func read<T: UnsafeRawBufferInitializable>(
3434
mode: PredicateMode,
3535
while predicate: (UInt8) -> Bool,
36-
as type: T.Type) async throws -> T
37-
{
36+
as type: T.Type
37+
) async throws -> T {
3838
return try await read(mode: mode, while: predicate) { bytes in
3939
return T(bytes)
4040
}

Tests/Stream/BufferedInputStream/main.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ test("BufferedInputStream") {
2828
return buffer
2929
}
3030

31-
expect(try await read(count: 5) == [0,1,2,3,4])
31+
expect(try await read(count: 5) == [0, 1, 2, 3, 4])
3232
expect(stream.buffered == 5)
33-
expect(try await read(count: 2) == [5,6])
33+
expect(try await read(count: 2) == [5, 6])
3434
expect(stream.buffered == 3)
35-
expect(try await read(count: 13) == [7,8,9,0,1,2,3,4,5,6,7,8,9])
35+
expect(try await read(count: 13) == [7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
3636
expect(stream.buffered == 0)
3737

38-
expect(try await read(count: 10) == [0,1,2,3,4,5,6,7,8,9])
38+
expect(try await read(count: 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
3939
expect(stream.buffered == 0)
4040

41-
expect(try await read(count: 13) == [0,1,2,3,4,5,6,7,8,9,10,11,12])
41+
expect(try await read(count: 12) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
4242
expect(stream.buffered == 0)
4343

44-
expect(try await read(count: 9) == [0,1,2,3,4,5,6,7,8])
44+
expect(try await read(count: 9) == [0, 1, 2, 3, 4, 5, 6, 7, 8])
4545
expect(stream.buffered == 1)
46-
expect(try await read(count: 13) == [9,0,1,2,3,4,5,6,7,8,9,10,11])
46+
expect(try await read(count: 12) == [9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
4747
expect(stream.buffered == 0)
4848
// test if stream resets if drained
4949
stream.clear()

0 commit comments

Comments
 (0)