pub struct RpcManager {
pub client_config: VoltClientConfiguration,
pub connect_url: String,
pub key_pair: SigningKeyPair,
pub relaying: bool,
pub next_id: u64,
pub rpcs: Arc<Mutex<HashMap<u64, Rpc>>>,
}
Fields§
§client_config: VoltClientConfiguration
§connect_url: String
§key_pair: SigningKeyPair
§relaying: bool
§next_id: u64
§rpcs: Arc<Mutex<HashMap<u64, Rpc>>>
Implementations§
Source§impl RpcManager
impl RpcManager
pub fn new() -> RpcManager
Sourcepub fn set_configuration(&mut self, config_json: &str) -> Result<String, String>
pub fn set_configuration(&mut self, config_json: &str) -> Result<String, String>
Initialise the client with the provided configuration. @param config_json The JSON configuration for the client, in stringified form. @returns The URL to connect to the Volt websocket server.
Sourcepub fn create_rpc_with_time(
&mut self,
method_name: &str,
token_time: u64,
service_json: &str,
) -> Result<u64, String>
pub fn create_rpc_with_time( &mut self, method_name: &str, token_time: u64, service_json: &str, ) -> Result<u64, String>
Create a new RPC method. @param method_name The name of the method to create. @param token_time The time in seconds since the Unix epoch for the rpc token. @param service_json The JSON string representing the service, or an empty string if this is a built-in service. @returns The ID of the new RPC method.
Sourcepub fn remove_rpc(&mut self, method_id: &u64)
pub fn remove_rpc(&mut self, method_id: &u64)
Remove an RPC method with the given method ID. @param method_id The ID of the RPC method to remove.
Sourcepub fn encode_payload(
&self,
method_id: &u64,
payload_json: &str,
) -> Result<Vec<u8>, String>
pub fn encode_payload( &self, method_id: &u64, payload_json: &str, ) -> Result<Vec<u8>, String>
Encodes and encrypts a JSON payload for the given method ID. @param method_id The method ID to encode the payload for. @param payload_json The JSON payload to encode. @returns The encoded and encrypted payload as a binary buffer.
Sourcepub fn decode_payload(&self, payload: Vec<u8>) -> Result<String, String>
pub fn decode_payload(&self, payload: Vec<u8>) -> Result<String, String>
Decode and decrypts a binary payload. @param payload The binary payload to decode. @returns The decoded payload as a JSON string.
Sourcepub fn pending_payload(&self, method_id: &u64) -> Result<Vec<u8>, String>
pub fn pending_payload(&self, method_id: &u64) -> Result<Vec<u8>, String>
Returns any pending payload for the given method ID. @param method_id The method ID to check for pending payloads. @returns The pending payload, or empty array if none.
Sourcepub fn sign_base64(&self, data: &str) -> Result<String, String>
pub fn sign_base64(&self, data: &str) -> Result<String, String>
Sign the provided data using the client’s private key. @param data The data to sign. @returns The signature of the data, encoded as a base64Url string.
Sourcepub fn public_key_pem(&self) -> String
pub fn public_key_pem(&self) -> String
Get the client’s public key in PEM format. @returns The client’s public key in PEM format.