Make parse(limit:_:) and withParseInput(_:) internal

Their closures take a ParseInput, which has no public members, so they
added unusable API to ByteBuffer, DispatchData, Data and [UInt8].
This commit is contained in:
Daniel Eggert committed 2026-11-24 09:48:19 +09:00
1 parent 6d15fe3856
commit 13ec89db9f
2 files changed
+6 -10

No files matched your search

@@ -73,10 +73,7 @@ internal protocol ParserInputBuffer {
}
/// A ``ParserInputBuffer`` the parser can also consume from, so that a caller does not have to trim
/// it by hand.
///
/// ``ConsumableParserInputBuffer/parse(limit:_:)`` is the entry point that trims: whatever the
/// parser consumed is discarded when it returns, including when it throws.
/// it by hand: the stream parsers discard whatever they consumed, including when they throw.
///
/// - Important: ``discardFirst(_:)`` must be O(1) amortised in the number of bytes discarded. A
/// conformer that moves the remaining bytes down instead makes a caller that trims after every
@@ -220,7 +217,7 @@ extension ParserInputBuffer {
/// default argument here would shadow a conformer's own witness, so a one-pass conformer would
/// silently take the generic path whenever the caller left the limit out — which is the common
/// case, and the failure is invisible.
public func withParseInput<R>(_ body: (inout ParseInput) throws -> R) rethrows -> R {
internal func withParseInput<R>(_ body: (inout ParseInput) throws -> R) rethrows -> R {
try withParseInput(limit: .max, body)
}
@@ -360,7 +357,7 @@ extension ConsumableParserInputBuffer {
/// - limit: The most bytes the parser may consume.
/// - body: A closure that reads through the cursor.
/// - Returns: Whatever `body` returns.
public mutating func parse<R>(
internal mutating func parse<R>(
limit: Int = .max,
_ body: (inout ParseInput) throws -> R
) rethrows -> R {
+3 -4
View File
@@ -161,10 +161,9 @@ internal func _span(_ bytes: UnsafeBufferPointer<UInt8>) -> Span<UInt8> {
///
/// If you are looking for how to give the parser bytes, you want ``ParserInputBuffer`` — in a
/// connection, ``IMAPInputBuffer``. `ParseInput` is `public` for one reason only: it appears in the
/// closure signature of ``ParserInputBuffer/withParseInput(limit:_:)`` and
/// ``ConsumableParserInputBuffer/parse(limit:_:)``, which a caller outside this module has to be able
/// to spell in order to conform. Everything that *reads* through a cursor — both initialisers, every
/// primitive, every combinator, and the read position itself — is `internal`.
/// closure signature of ``ParserInputBuffer/withParseInput(limit:_:)``, which a caller outside this
/// module has to be able to spell in order to conform. Everything that *reads* through a cursor — both
/// initialisers, every primitive, every combinator, and the read position itself — is `internal`.
///
/// So there is nothing a client can do with one, and nothing it needs to do: no public API takes a
/// cursor. ``CommandParser/parseCommandStream(buffer:)`` and