PrivMX DOCS
API Reference/PrivMX Endpoint Swift Extra/Extensions

privmx.endpoint.core.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.

Params

lhs

privmx.endpoint.core.Buffer

The left-hand side Buffer instance.

rhs

privmx.endpoint.core.Buffer

The right-hand side Buffer instance.

public static func == (lhs: privmx.endpoint.core.Buffer, rhs: privmx.endpoint.core.Buffer) -> Bool

Returns

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.

Params

data

Data

The Data object to convert.

public static func from(_ data: Data) -> privmx.endpoint.core.Buffer

Returns

privmx.endpoint.core.Buffer · A new privmx.endpoint.core.Buffer instance.

from(hex:)

Decodes a string in Hex.

Params

hex

std.string

string to decode

public static func from(
hex: std.string
) throws -> privmx.endpoint.core.Buffer

Returns

privmx.endpoint.core.Buffer · decoded Buffer

from(base32:)

Decodes a string in Base32.

Params

base32

std.string

string to decode

public static func from(
base32: std.string
) throws -> privmx.endpoint.core.Buffer

Returns

privmx.endpoint.core.Buffer · decoded Buffer

from(base64:)

Decodes a string in Base64.

Params

base64

std.string

string to decode

public static func from(
base64: std.string
) throws -> privmx.endpoint.core.Buffer

Returns

privmx.endpoint.core.Buffer · decoded Buffer

Methods

hash(into:)

Generates a hash value for the buffer. This function hashes the underlying byte string of the buffer.

Params

hasher

inout Hasher

The Hasher instance used to compute the hash value.

public func hash(into hasher: inout Hasher)

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?

Returns

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?

Returns

String? · A new String instance if the conversion is successful, otherwise nil.

toHex()

Creates a string representing this Buffer in Hex format.

public func toHex(
) throws -> std.string

Returns

std.string ·

toBase32()

Creates a string representing this Buffer in Base32 format.

public func toBase32(
) throws -> std.string

Returns

std.string ·

toBase64()

Creates a string representing this Buffer in Base64 format.

public func toBase64(
) throws -> std.string

Returns

std.string ·

We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.

PrivMX Endpoint Swift v2.3

This package is not up to date with the core documentation. Some of the features you've seen described in other parts of the documentation might not be mentioned here. Those changes do not influence compatibility, however