RESPTranslator
public struct RESPTranslator
A helper object for translating between raw bytes and Swift types according to the Redis Serialization Protocol (RESP).
-
Undocumented
Declaration
Swift
public init()
-
Writes the value into the desired
ByteBuffer
in RESP format.Declaration
Swift
public func write<Value>(_ value: Value, into out: inout ByteBuffer) where Value : RESPValueConvertible
Parameters
value
The value to write into the buffer.
out
The
ByteBuffer
that should be written to.
-
Possible errors thrown while parsing RESP messages.
Important
Any of these errors should be considered a BUG.Please file a bug at https://www.gitlab.com/mordil/RediStack/-/issues.
See moreDeclaration
Swift
public struct ParsingError : LocalizedError, Equatable
-
Attempts to parse a
RESPValue
from theByteBuffer
.Important
The providedbuffer
will have its reader index moved on a successful parse.Throws
RESPTranslator.ParsingError.invalidToken
if the first byte is not an expected RESP Data Type token.
Declaration
Swift
public func parseBytes(from buffer: inout ByteBuffer) throws -> RESPValue?
Parameters
buffer
The buffer that contains the bytes that need to be parsed.
Return Value
The parsed
RESPValue
or nil.