NPRPC docs

class NPRPCObject

Swift

class NPRPCObject

Swift representation of a remote C++ nprpc::Object All data is accessed through the C++ object via the bridge - no duplication

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:20

Constructors

required init(from decoder: Decoder) throws

Decodes a reference from its IOR string. Throws for a malformed one.

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:43

required init(handle: UnsafeMutableRawPointer)

Initialize with a C++ Object handle

handle
Opaque pointer to nprpc::Object (takes ownership of reference)

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:282

init()

Create an empty/null object (not connected to any C++ object) Used as a placeholder in struct default values

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:288

Properties

class var classId: String { get }

Class ID for this proxy type, used for type checking in narrow. Generated subclasses override it with their interface's id.

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:23

var classId: String { get }

The class ID string identifying the interface type

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:72

var data: NPRPCObjectData { get }

Get ObjectId data for marshalling to remote calls

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:267

var endpoint: NPRPCEndpoint { get }

The currently selected endpoint for communication

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:92

var flags: UInt16 { get }

Object flags (persistence, etc.)

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:67

let handle: UnsafeMutableRawPointer

Opaque handle to C++ nprpc::Object

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:28

var objectId: UInt64 { get }

The unique object ID within its POA

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:57

var origin: [UInt8] { get }

The origin UUID of the process that created this object

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:82

var poaIdx: UInt16 { get }

The POA index where this object is activated

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:62

var timeout: UInt32 { get set }

Timeout in milliseconds for RPC calls

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:101

var urls: String { get }

Available endpoint URLs for this object

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:77

Methods

@discardableResult func addRef() -> UInt32

Increment reference count

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:110

func encode(to encoder: Encoder) throws

Encodes the reference as its IOR string (ObjectId.toString()).

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:37

static func fromObjectId(_ objectId: detail.ObjectId) -> NPRPCObject?

Create an NPRPCObject from ObjectId data

objectId
The ObjectId containing all reference data

Returns A new NPRPCObject, or nil if creation failed

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:319

static func fromString(_ str: String) -> NPRPCObject?

Create an NPRPCObject from a serialized string (NPRPC IOR format)

str
The serialized object reference string

Returns A new NPRPCObject, or nil if parsing failed

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:309

@discardableResult func release() -> UInt32

Decrement reference count (called automatically in deinit)

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:116

@discardableResult func selectEndpoint() -> Bool

Select the best available endpoint for communication

Returns true if an endpoint was selected, false if none available

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:126

@discardableResult func selectEndpoint(_ endpoint: NPRPCEndpoint) -> Bool

Select endpoint with a preferred endpoint hint

endpoint
The preferred endpoint to try to select

Returns true if the endpoint was selected, false if not available

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:134

func sendAsync(buffer: FlatBuffer, timeout: UInt32) async throws

Send a request asynchronously with async/await support

  • Throws: RpcError on communication failure
buffer
The FlatBuffer containing the request (ownership transferred)
timeout
Timeout in milliseconds

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:167

func sendAsyncReceive(buffer: FlatBuffer, timeout: UInt32) async throws -> FlatBuffer

Send a request asynchronously and receive the response with async/await support Use this for async methods that have output parameters

  • Throws: RpcError on communication failure
buffer
The FlatBuffer containing the request (ownership transferred)
timeout
Timeout in milliseconds

Returns FlatBuffer containing the response

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:216

@discardableResult func sendUnreliable(buffer: FlatBuffer) -> Bool

Fire-and-forget send for IDL [unreliable] methods.

Writes the request and returns. Unlike sendAsync / sendAsyncReceive, this never waits for a reply and must not occupy the transport's reply-wait queue — the server deliberately sends nothing back for [unreliable] (e.g. LavaUI Present). Using a reply waiter there times out after ~1s and, on shared memory, steals later real replies that are matched by queue position.

buffer
Request buffer; storage is consumed (moved) like the other send paths.

Returns true if the transport accepted the write.

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:158

func toString() -> String

Serialize this object reference to a string (similar to CORBA IOR) Format: "NPRPC1:<base64_encoded_data>" This string can be shared and used to recreate the object reference elsewhere.

nprpc_swift/Sources/NPRPC/NPRPCObject.swift:298