PrivMX DOCS
API Reference/PrivMX Endpoint Swift Extra/Extensions

Data

An extension for Data that provides helper methods for converting between Data and privmx.endpoint.core.Buffer as well as C++ std.string.

Static Methods

from(hex:)

Decodes a string in Hex.

Params

hex

String

string to decode

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

Returns

privmx.endpoint.core.Buffer · decoded Data

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 Data

from(base32:)

Decodes a string in Base32.

Params

base32

String

string to decode

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

Returns

privmx.endpoint.core.Buffer · decoded Data

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 Data

from(base64:)

Decodes a string in Base64.

Params

base64

String

string to decode

public static func from(
base64: String
) throws -> Data

Returns

Data · decoded Data

from(base64:)

Decodes a string in Base64.

Params

base64

std.string

string to decode

public static func from(
base64: std.string
) throws -> Data

Returns

Data · decoded Data

Methods

asBuffer()

Converts the contents of this Data instance into a privmx.endpoint.core.Buffer. This helper function creates a Buffer instance from the bytes of the Data object.

public func asBuffer() -> privmx.endpoint.core.Buffer

Returns

privmx.endpoint.core.Buffer · A privmx.endpoint.core.Buffer instance representing the data.

init(from:)

Initializes a Data object from the bytes of a privmx.endpoint.core.Buffer. This initializer converts the contents of the provided Buffer into a Data instance.

Params

buffer

privmx.endpoint.core.Buffer

The privmx.endpoint.core.Buffer to convert to Data.

public init(from buffer: privmx.endpoint.core.Buffer) throws

rawCppString()

Converts the underlying Data to a C++ std.string. This helper function creates a std.string representation of the Data object by interpreting the data as a C string.

public func rawCppString() -> std.string

Returns

std.string · A std.string representation of the Data contents.

init(from:)

Initializes a Data object from a C++ std.string. This initializer creates a Data instance by converting the provided C++ std.string into a UTF-8 encoded Data object.

Params

str

std.string

The C++ std.string to convert to Data.

public init(from str: std.string)

Returns

`` · A Data representation of the given std.string.

toHex()

Encodes Data to a string in Hex format.

public func toHex(
) throws -> String

Returns

String ·

toBase32()

Encodes Data to a string in Base32 format.

public func toBase32(
) throws -> String

Returns

String ·

toBase64()

Encodes Data to a string in Base64 format.

public func toBase64(
) throws -> String

Returns

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.