class rgpot::RpcClient

Overview

Move-only RAII wrapper around rgpot_rpc_client_t. More…

#include <rpc_client.hpp>
 
class RpcClient {
public:
    // construction
 
    RpcClient(const std::string& host, uint16_t port);
    RpcClient(RpcClient&& other);
    RpcClient(const RpcClient&);
    ~RpcClient();
 
    // methods
 
    RpcClient& operator=(RpcClient&& other);
    RpcClient& operator=(const RpcClient&);
    CalcResult calculate(const InputSpec& input);
};

Detailed Documentation

Move-only RAII wrapper around rgpot_rpc_client_t.

Owns an opaque RPC client handle allocated by the Rust core. The connection is established during construction and torn down on destruction via rgpot_rpc_client_free(). The class is non-copyable; move semantics transfer ownership of the connection.

Construction

RpcClient(const std::string& host, uint16_t port)

Connect to a remote rgpot server.

Calls rgpot_rpc_client_new() and throws on failure.

Parameters:

host

Hostname or IP address of the server.

port

TCP port the server listens on.

rgpot::Error

if the connection cannot be established.

RpcClient(RpcClient&& other)

Move constructor — transfers connection ownership.

Parameters:

other

Client to move from; left in a null state.

~RpcClient()

Destructor — disconnects and frees the Rust-side client.

Safe to call on a moved-from handle (internal pointer is nullptr).

Methods

RpcClient& operator=(RpcClient&& other)

Move assignment — releases current connection, transfers ownership.

Parameters:

other

Client to move from; left in a null state.

Returns:

Reference to *this.

CalcResult calculate(const InputSpec& input)

Perform a remote force/energy calculation.

Serialises the input via Cap’n Proto, sends the request to the server, and deserialises the response into a CalcResult.

Parameters:

input

The atomic configuration to evaluate.

rgpot::Error

on RPC transport or server-side failure.

Returns:

A CalcResult containing energy, variance, and forces.