Skip to content

Commit 06b9f98

Browse files
authored
Make async/await API public (#552)
1 parent f3830d1 commit 06b9f98

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

Sources/AsyncHTTPClient/AsyncAwait/HTTPClient+execute.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extension HTTPClient {
2727
/// - deadline: Point in time by which the request must complete.
2828
/// - logger: The logger to use for this request.
2929
/// - Returns: The response to the request. Note that the `body` of the response may not yet have been fully received.
30-
func execute(
30+
public func execute(
3131
_ request: HTTPClientRequest,
3232
deadline: NIODeadline,
3333
logger: Logger? = nil
@@ -52,7 +52,7 @@ extension HTTPClient {
5252
/// - timeout: time the the request has to complete.
5353
/// - logger: The logger to use for this request.
5454
/// - Returns: The response to the request. Note that the `body` of the response may not yet have been fully received.
55-
func execute(
55+
public func execute(
5656
_ request: HTTPClientRequest,
5757
timeout: TimeAmount,
5858
logger: Logger? = nil

Sources/AsyncHTTPClient/AsyncAwait/HTTPClient+shutdown.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
extension HTTPClient {
1818
/// Shuts down the client and `EventLoopGroup` if it was created by the client.
1919
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
20-
func shutdown() async throws {
20+
public func shutdown() async throws {
2121
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) in
2222
self.shutdown { error in
2323
switch error {

Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest.swift

+16-16
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ import NIOCore
1717
import NIOHTTP1
1818

1919
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
20-
struct HTTPClientRequest {
21-
var url: String
22-
var method: HTTPMethod
23-
var headers: HTTPHeaders
20+
public struct HTTPClientRequest {
21+
public var url: String
22+
public var method: HTTPMethod
23+
public var headers: HTTPHeaders
2424

25-
var body: Body?
25+
public var body: Body?
2626

27-
init(url: String) {
27+
public init(url: String) {
2828
self.url = url
2929
self.method = .GET
3030
self.headers = .init()
@@ -34,7 +34,7 @@ struct HTTPClientRequest {
3434

3535
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
3636
extension HTTPClientRequest {
37-
struct Body {
37+
public struct Body {
3838
@usableFromInline
3939
internal enum Mode {
4040
case asyncSequence(length: RequestBodyLength, (ByteBufferAllocator) async throws -> ByteBuffer?)
@@ -54,12 +54,12 @@ extension HTTPClientRequest {
5454

5555
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
5656
extension HTTPClientRequest.Body {
57-
static func bytes(_ byteBuffer: ByteBuffer) -> Self {
57+
public static func bytes(_ byteBuffer: ByteBuffer) -> Self {
5858
self.init(.byteBuffer(byteBuffer))
5959
}
6060

6161
@inlinable
62-
static func bytes<Bytes: RandomAccessCollection>(
62+
public static func bytes<Bytes: RandomAccessCollection>(
6363
_ bytes: Bytes
6464
) -> Self where Bytes.Element == UInt8 {
6565
self.init(.sequence(
@@ -76,7 +76,7 @@ extension HTTPClientRequest.Body {
7676
}
7777

7878
@inlinable
79-
static func bytes<Bytes: Sequence>(
79+
public static func bytes<Bytes: Sequence>(
8080
_ bytes: Bytes,
8181
length: Length
8282
) -> Self where Bytes.Element == UInt8 {
@@ -94,7 +94,7 @@ extension HTTPClientRequest.Body {
9494
}
9595

9696
@inlinable
97-
static func bytes<Bytes: Collection>(
97+
public static func bytes<Bytes: Collection>(
9898
_ bytes: Bytes,
9999
length: Length
100100
) -> Self where Bytes.Element == UInt8 {
@@ -112,7 +112,7 @@ extension HTTPClientRequest.Body {
112112
}
113113

114114
@inlinable
115-
static func stream<SequenceOfBytes: AsyncSequence>(
115+
public static func stream<SequenceOfBytes: AsyncSequence>(
116116
_ sequenceOfBytes: SequenceOfBytes,
117117
length: Length
118118
) -> Self where SequenceOfBytes.Element == ByteBuffer {
@@ -124,7 +124,7 @@ extension HTTPClientRequest.Body {
124124
}
125125

126126
@inlinable
127-
static func stream<Bytes: AsyncSequence>(
127+
public static func stream<Bytes: AsyncSequence>(
128128
_ bytes: Bytes,
129129
length: Length
130130
) -> Self where Bytes.Element == UInt8 {
@@ -157,11 +157,11 @@ extension Optional where Wrapped == HTTPClientRequest.Body {
157157

158158
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
159159
extension HTTPClientRequest.Body {
160-
struct Length {
160+
public struct Length {
161161
/// size of the request body is not known before starting the request
162-
static let unknown: Self = .init(storage: .unknown)
162+
public static let unknown: Self = .init(storage: .unknown)
163163
/// size of the request body is fixed and exactly `count` bytes
164-
static func known(_ count: Int) -> Self {
164+
public static func known(_ count: Int) -> Self {
165165
.init(storage: .known(count))
166166
}
167167

Sources/AsyncHTTPClient/AsyncAwait/HTTPClientResponse.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import NIOCore
1717
import NIOHTTP1
1818

1919
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
20-
struct HTTPClientResponse {
21-
var version: HTTPVersion
22-
var status: HTTPResponseStatus
23-
var headers: HTTPHeaders
24-
var body: Body
20+
public struct HTTPClientResponse {
21+
public var version: HTTPVersion
22+
public var status: HTTPResponseStatus
23+
public var headers: HTTPHeaders
24+
public var body: Body
2525

26-
struct Body {
26+
public struct Body {
2727
private let bag: Transaction
2828
private let reference: ResponseRef
2929

@@ -48,21 +48,21 @@ struct HTTPClientResponse {
4848

4949
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
5050
extension HTTPClientResponse.Body: AsyncSequence {
51-
typealias Element = AsyncIterator.Element
51+
public typealias Element = AsyncIterator.Element
5252

53-
struct AsyncIterator: AsyncIteratorProtocol {
53+
public struct AsyncIterator: AsyncIteratorProtocol {
5454
private let stream: IteratorStream
5555

5656
fileprivate init(stream: IteratorStream) {
5757
self.stream = stream
5858
}
5959

60-
mutating func next() async throws -> ByteBuffer? {
60+
public mutating func next() async throws -> ByteBuffer? {
6161
try await self.stream.next()
6262
}
6363
}
6464

65-
func makeAsyncIterator() -> AsyncIterator {
65+
public func makeAsyncIterator() -> AsyncIterator {
6666
AsyncIterator(stream: IteratorStream(bag: self.bag))
6767
}
6868
}

0 commit comments

Comments
 (0)