Buffer
'Buffer' provides simple string buffer implementation.
Static Methods
==(::)
Compares two `Buffer` instances for equality. This function compares the underlying byte strings of the two buffers.
public static func == (lhs: privmx.endpoint.core.Buffer, rhs: privmx.endpoint.core.Buffer) -> Bool
Name | Type | Description |
---|---|---|
lhs | privmx.endpoint.core.Buffer | The left-hand side `Buffer` instance. |
rhs | privmx.endpoint.core.Buffer | The right-hand side `Buffer` instance. |
Type | Description |
---|---|
Bool | `true` if both buffers contain the same byte string, otherwise `false`. |
from(_:)
Creates a new `Buffer` instance from a `Data` object. This helper function converts the provided `Data` object into a new `Buffer` instance.
public static func from(_ data: Data) -> privmx.endpoint.core.Buffer
Name | Type | Description |
---|---|---|
data | Data | The `Data` object to convert. |
Type | Description |
---|---|
privmx.endpoint.core.Buffer | A new `privmx.endpoint.core.Buffer` instance. |
Methods
hash(into:)
Generates a hash value for the buffer. This function hashes the underlying byte string of the buffer.
public func hash(into hasher: inout Hasher)
Name | Type | Description |
---|---|---|
hasher | inout Hasher | The `Hasher` instance used to compute the hash value. |
getData()
Creates a new `Data` instance from the buffer’s underlying bytes. This helper function converts the buffer into a `Data` object.
public func getData() -> Data?
Type | Description |
---|---|
Data? | A new `Data` instance if the conversion is successful, otherwise `nil`. |
getString()
Creates a new `String` instance from the buffer’s underlying bytes. This helper function converts the buffer into a UTF-8 `String`.
public func getString() -> String?
Type | Description |
---|---|
String? | A new `String` instance if the conversion is successful, otherwise `nil`. |