Skip to content

Commit 87618be

Browse files
committed
Make RedisData convenience properties public
1 parent 3a26585 commit 87618be

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

Sources/NIORedis/Data/RedisData.swift

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,46 +45,44 @@ extension RedisData: ExpressibleByIntegerLiteral {
4545
}
4646
}
4747

48-
// Internal convienence computed properties
49-
5048
extension RedisData {
51-
/// Extracts the simple/bulk string as a `String`.
52-
/// - Note: This attempts to convert a `bulkString` to a `String` using UTF-8 encoding and may return nil.
53-
var string: String? {
49+
/// Extracted value of `simpleString` and `bulkString` representations.
50+
/// - Important: `bulkString` conversions to `String` assume UTF-8 encoding. Use the `data` property in other encodings.
51+
public var string: String? {
5452
switch self {
5553
case .simpleString(let string): return string
5654
case .bulkString(let data): return String(bytes: data, encoding: .utf8)
5755
default: return nil
5856
}
5957
}
6058

61-
/// Extracts the binary data from a Redis BulkString
62-
var data: Data? {
59+
/// Extracted binary data from `bulkString` representations.
60+
public var data: Data? {
6361
guard case .bulkString(let data) = self else { return nil }
6462
return data
6563
}
6664

67-
/// Extracts an array type from this data
68-
var array: [RedisData]? {
65+
/// Extracted container of data elements from `array` representations.
66+
public var array: [RedisData]? {
6967
guard case .array(let array) = self else { return nil }
7068
return array
7169
}
7270

73-
/// Extracts an array type from this data
71+
/// Extracted value from `integer` representations.
7472
var int: Int? {
7573
guard case .integer(let int) = self else { return nil }
7674
return int
7775
}
7876

79-
/// `true` if this data is null.
77+
/// Returns `true` if this data is a "null" value from Redis.
8078
var isNull: Bool {
8179
switch self {
8280
case .null: return true
8381
default: return false
8482
}
8583
}
8684

87-
/// Extracts an error from this data
85+
/// Extracted value from `error` representations.
8886
var error: RedisError? {
8987
switch self {
9088
case .error(let error): return error

0 commit comments

Comments
 (0)