RESPValue
public enum RESPValue
extension RESPValue: CustomStringConvertible
extension RESPValue: Equatable
extension RESPValue: RESPValueConvertible
A representation of a Redis Serialization Protocol (RESP) primitive value.
This enum representation should be used only as a temporary intermediate representation of values, and should be sent to a Redis server or converted to Swift types as soon as possible.
Redis servers expect a single message packed into an .array
, with all elements being .bulkString
representations of values. As such, all initializers
convert to .bulkString
representations, as well as default conformances for RESPValueConvertible
.
Each case of this type is a different listing in the RESP specification, and several computed properties are available to consistently convert values into Swift types.
-
Undocumented
Declaration
Swift
case null
-
Undocumented
Declaration
Swift
case simpleString(ByteBuffer)
-
Undocumented
Declaration
Swift
case bulkString(ByteBuffer?)
-
Undocumented
Declaration
Swift
case error(RedisError)
-
Undocumented
Declaration
Swift
case integer(Int)
-
Undocumented
Declaration
Swift
case array([RESPValue])
-
Stores the representation determined by the
RESPValueConvertible
value.Important
If you are sending this value to a Redis server, the type should be convertible to a.bulkString
.Declaration
Swift
@inlinable public init<Value>(from value: Value) where Value : RESPValueConvertible
Parameters
value
The value that needs to be converted and stored in
RESPValue
format.
-
See
CustomStringConvertible.description
Declaration
Swift
public var description: String { get }
-
The unwrapped value for
.array
representations.Note
This is a shorthand forArray<RESPValue>.init(fromRESP:)
Declaration
Swift
public var array: [RESPValue]? { get }
-
The unwrapped value as an
Int
.Note
This is a shorthand forInt(fromRESP:)
.Declaration
Swift
public var int: Int? { get }
-
Returns
true
if the unwrapped value is.null
.Declaration
Swift
public var isNull: Bool { get }
-
The unwrapped
RedisError
that was returned from Redis.Note
This is a shorthand forRedisError(fromRESP:)
.Declaration
Swift
public var error: RedisError? { get }
-
The unwrapped
NIO.ByteBuffer
for.simpleString
or.bulkString
representations.Declaration
Swift
public var byteBuffer: ByteBuffer? { get }
-
The value as a UTF-8
String
representation.Note
This is a shorthand forString.init(fromRESP:)
.Declaration
Swift
public var string: String? { get }
-
The data stored in either a
.simpleString
or.bulkString
represented asFoundation.Data
instead ofNIO.ByteBuffer
.Note
This is a shorthand forData.init(fromRESP:)
.Declaration
Swift
public var data: Data? { get }
-
The raw bytes stored in the
.simpleString
or.bulkString
representations.Note
This is a shorthand forArray<UInt8>.init(fromRESP:)
.Declaration
Swift
public var bytes: [UInt8]? { get }
-
Declaration
Swift
public static func == (lhs: RESPValue, rhs: RESPValue) -> Bool
-
Declaration
Swift
public init?(fromRESP value: RESPValue)
-
Declaration
Swift
public func convertedToRESPValue() -> RESPValue