Add EncodeBuffer.writeByte / writeDecimal / writeLiteralHeader /
writeRedactedByteCount and use them for every numeric interpolation
in encoders. writeString("…\(x)…") sites become separate writeString
calls; quote-wrapped ones ("\"\(x)\"") stay. writeMailboxStatus
writes each attribute directly instead of building (String, String)
pairs. Output unchanged for valid values; avoids String formatting and
allocation. Invalid (negative) FullDate/FullTime fields now pad after
the sign: -0005, not 00-5.
writeLiteralHeader takes LiteralSynchronization (`{n+}`) and
LiteralKind (`~{n}`) enums.
As EncodeBuffer methods, `self.write(if:) { self.write… }` borrows the
buffer while the closure mutates it, forcing a copy and a CoW on the
first write inside the closure.
Hand edit: Sources/NIOIMAPCore/ByteBuffer+WriteLiteral.swift, which
defines the free functions. Call sites converted with:
git ls-files -z 'Sources/*.swift' 'Tests/*.swift' | xargs -0 perl -pi -e \
's/\b(?:self\.buffer|self|buffer)\.(writeIfExists\(|write\(if:)/$1/g'
* [CI] Adopt GitHub Actions
# Motivation
We want to adopt GitHub actions in all of our Swift repositories to replace our current Jenkins CI.
# Modification
This PR adopts the reusable workflows from NIO and the swiftlang organization to ensure soundness and test coverage. Additionally, this PR enables a sematic label check and adds a `release.yml` to make releasing this package easy.
# Result
Modern CI and release flow.
With this PR the implementation of `CustomDebugStringConvertible` generally uses new `makeDescription` convenience methods on the three encode buffers, e.g.:
```swift
extension ResponseEncodeBuffer {
static func makeDescription(_ closure: (inout ResponseEncodeBuffer) -> Void) -> String
}
```
such that conformance can be implemented as e.g.
```swift
extension Command: CustomDebugStringConvertible {
public var debugDescription: String {
CommandEncodeBuffer.makeDescription {
$0.writeCommand(self)
}
}
}
```
This also adds `CustomDebugStringConvertible` to `MessageAttribute` and `StreamingKind`.
Resolves#662
Command/Response Encoder can be configured using loggingMode. If turned on then user-sensitive strings won't be encoding, but any metadata will.
For example, 1 LOGIN username password becomes 1 LOGIN "" "", thereby hiding the user's information.
Noticed by Matt, we had, for example, Command.tagged, but Response.taggedResponse. In general I've removed the superfluous Response at the end of each case.
Resolves#556
We've talked quite a bit offline, and decided that for now @_spi is the way to go, as it avoids build system issues. The goal is to remove the number of underscored public types and fields.
* Servers now can send authentication challenges
* Soundness
* Fix tests
* Change to use Response
* Docs
* Soundness
* work around SR-14394
* Update Sources/NIOIMAPCore/Grammar/Response/Response.swift
Co-authored-by: Daniel Eggert <daniel.eggert@hoerbuch.dk>
* Fix compile on 5.2
Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
Co-authored-by: Daniel Eggert <daniel.eggert@hoerbuch.dk>
* Use encoding options specific to the transport direction.
* Add description to precondition failure.
* Make properties on EncodingOptions public.
* Rename files.
* Change APPEND to use CommandEncodingOptions.