Struct RpcManager

Source
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

Source

pub fn new() -> RpcManager

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn drop(self)

Trait Implementations§

Source§

impl Drop for RpcManager

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.