Skip to main content
reference

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

TypeDescription
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.

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

NameTypeDescription
bufferprivmx.endpoint.core.BufferThe `privmx.endpoint.core.Buffer` to convert to `Data`.

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

TypeDescription
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.

public init(from str: std.string)

NameTypeDescription
strstd.stringThe C++ `std.string` to convert to `Data`.

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