Skip to content

Commit

Permalink
Rename write
Browse files Browse the repository at this point in the history
  • Loading branch information
swhitty committed Feb 20, 2022
1 parent 0e2a362 commit bb1615c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sources/HTTPConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct HTTPConnection {
}

func sendResponse(_ response: HTTPResponse) async throws {
try await socket.writeData(HTTPResponseEncoder.encodeResponse(response))
try await socket.write(HTTPResponseEncoder.encodeResponse(response))
}

func close() async throws {
Expand Down
8 changes: 4 additions & 4 deletions Sources/Socket/AsyncSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ struct AsyncSocket: Sendable {
} while true
}

func writeData(_ data: Data) async throws {
func write(_ data: Data) async throws {
var sent = data.startIndex
while sent < data.endIndex {
sent = try await writeData(data, from: sent)
sent = try await write(data, from: sent)
}
}

private func writeData(_ data: Data, from index: Data.Index) async throws -> Data.Index {
private func write(_ data: Data, from index: Data.Index) async throws -> Data.Index {
repeat {
do {
return try socket.writeData(data, from: index)
return try socket.write(data, from: index)
} catch SocketError.blocked {
try await pool.suspend(untilReady: socket)
} catch {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Socket/Socket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ struct Socket: Sendable, Hashable {
}
}

func writeData(_ data: Data, from index: Data.Index) throws -> Data.Index {
func write(_ data: Data, from index: Data.Index) throws -> Data.Index {
guard index < data.endIndex else { return data.endIndex }
return try data.withUnsafeBytes {
guard let baseAddress = $0.baseAddress else {
Expand Down

0 comments on commit bb1615c

Please sign in to comment.