pub struct HttpRpcClient { /* private fields */ }Expand description
HTTP RPC client
Makes RPC calls to the gateway over HTTP POST requests. Supports both plain HTTP (dev mode) and mTLS (production).
Implementations§
Source§impl HttpRpcClient
impl HttpRpcClient
Sourcepub fn new(
gateway_url: impl Into<String>,
content_type: ContentType,
) -> HttpRpcClient
pub fn new( gateway_url: impl Into<String>, content_type: ContentType, ) -> HttpRpcClient
Create a new HTTP RPC client (plain HTTP, no TLS)
Sourcepub fn with_timeout(self, timeout: Duration) -> HttpRpcClient
pub fn with_timeout(self, timeout: Duration) -> HttpRpcClient
Set the request timeout
Sourcepub fn with_mtls(
gateway_url: impl Into<String>,
content_type: ContentType,
cert_path: impl AsRef<Path>,
key_path: impl AsRef<Path>,
ca_cert_path: impl AsRef<Path>,
) -> Result<HttpRpcClient, Error>
pub fn with_mtls( gateway_url: impl Into<String>, content_type: ContentType, cert_path: impl AsRef<Path>, key_path: impl AsRef<Path>, ca_cert_path: impl AsRef<Path>, ) -> Result<HttpRpcClient, Error>
Create a new HTTP RPC client with mTLS
Sourcepub fn json(gateway_url: impl Into<String>) -> HttpRpcClient
pub fn json(gateway_url: impl Into<String>) -> HttpRpcClient
Create a JSON client (human-readable, debugging)
Sourcepub fn protobuf(gateway_url: impl Into<String>) -> HttpRpcClient
pub fn protobuf(gateway_url: impl Into<String>) -> HttpRpcClient
Create a Protobuf client (efficient, production)
Sourcepub fn json_mtls(
gateway_url: impl Into<String>,
cert_path: impl AsRef<Path>,
key_path: impl AsRef<Path>,
ca_cert_path: impl AsRef<Path>,
) -> Result<HttpRpcClient, Error>
pub fn json_mtls( gateway_url: impl Into<String>, cert_path: impl AsRef<Path>, key_path: impl AsRef<Path>, ca_cert_path: impl AsRef<Path>, ) -> Result<HttpRpcClient, Error>
Create a JSON client with mTLS
Sourcepub fn protobuf_mtls(
gateway_url: impl Into<String>,
cert_path: impl AsRef<Path>,
key_path: impl AsRef<Path>,
ca_cert_path: impl AsRef<Path>,
) -> Result<HttpRpcClient, Error>
pub fn protobuf_mtls( gateway_url: impl Into<String>, cert_path: impl AsRef<Path>, key_path: impl AsRef<Path>, ca_cert_path: impl AsRef<Path>, ) -> Result<HttpRpcClient, Error>
Create a Protobuf client with mTLS
Sourcepub async fn call(&self, request: RpcRequest) -> Result<RpcResponse, Error>
pub async fn call(&self, request: RpcRequest) -> Result<RpcResponse, Error>
Make an RPC call
Sourcepub fn gateway_url(&self) -> &str
pub fn gateway_url(&self) -> &str
Get the gateway URL
Sourcepub fn content_type(&self) -> ContentType
pub fn content_type(&self) -> ContentType
Get the content type
Sourcepub async fn send(
&self,
message: &SynapseMessage,
) -> Result<SynapseMessage, Error>
pub async fn send( &self, message: &SynapseMessage, ) -> Result<SynapseMessage, Error>
Send a raw SynapseMessage and receive a response
Auto Trait Implementations§
impl Freeze for HttpRpcClient
impl !RefUnwindSafe for HttpRpcClient
impl Send for HttpRpcClient
impl Sync for HttpRpcClient
impl Unpin for HttpRpcClient
impl UnsafeUnpin for HttpRpcClient
impl !UnwindSafe for HttpRpcClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more