pub struct RpcClientImpl<S: Signer, T: Transport + 'static> {
pub signer: S,
pub transport: T,
pub server_verifying_key: Option<VerifyingKey>,
/* private fields */
}Expand description
Unified RPC client. Evolved from ZmqClient — same envelope, timeout, and resilience logic, parameterized over transport and signing.
Fields§
§signer: S§transport: T§server_verifying_key: Option<VerifyingKey>Implementations§
Source§impl<S: Signer, T: Transport + 'static> RpcClientImpl<S, T>
impl<S: Signer, T: Transport + 'static> RpcClientImpl<S, T>
Sourcepub fn new(
signer: S,
transport: T,
server_verifying_key: Option<VerifyingKey>,
) -> Self
pub fn new( signer: S, transport: T, server_verifying_key: Option<VerifyingKey>, ) -> Self
Create a new RPC client.
server_verifying_key: None skips response signature verification
(TLS cert pinning still protects the connection).
Sourcepub fn with_response_pq_store(self, pq_store: Arc<dyn PqTrustStore>) -> Self
pub fn with_response_pq_store(self, pq_store: Arc<dyn PqTrustStore>) -> Self
Enforce Hybrid (EdDSA + ML-DSA-65) verification of responses (#275),
anchoring the server’s ML-DSA-65 key via pq_store. Under this policy a
classical-only, stripped-outer, self-cert, or unanchored response is
REJECTED (fail-closed, no silent downgrade). Mirrors the request-side
Hybrid verify config.
Sourcepub fn with_request_kem_store(self, kem_store: Arc<dyn KemTrustStore>) -> Self
pub fn with_request_kem_store(self, kem_store: Arc<dyn KemTrustStore>) -> Self
Set the anchored #mesh-kem recipient key store used to encrypt request
envelopes when the selected transport forbids cleartext.
pub fn with_pre_seal_guard(self, guard: Arc<dyn PreSealGuard>) -> Self
pub fn with_browser_provisioning_binding( self, binding: BrowserRequestBinding, ) -> Result<Self>
Sourcepub fn with_federate_proof_provider(
self,
provider: Arc<dyn FederateProofProvider>,
) -> Self
pub fn with_federate_proof_provider( self, provider: Arc<dyn FederateProofProvider>, ) -> Self
Enable the dedicated Federate proof sender on this client. The provider is called separately for each request, after payload binding and recipient generation, immediately before the envelope is sealed.
Sourcepub fn with_response_verify_policy(self, policy: CryptoPolicy) -> Self
pub fn with_response_verify_policy(self, policy: CryptoPolicy) -> Self
Set the response-verify policy explicitly (advanced). Under Hybrid a
PQ trust store MUST also be set via Self::with_response_pq_store.
Setting this pins the policy for this client and bypasses the process-
global response default consulted by Self::unwrap_response.
Sourcepub fn with_token_provider<F>(self, f: F) -> Self
pub fn with_token_provider<F>(self, f: F) -> Self
Set a dynamic token provider called on every RPC request.
The closure is called once per call() / call_with_options() invocation
so short-lived tokens (OAuth at+jwt, WIT) are always fresh without
reconstructing the client. On WASM, wrap js_sys::Function in a
Send + Sync newtype before passing it here (WASM is single-threaded).
Sourcepub fn with_default_jwt(self, token: String) -> Self
pub fn with_default_jwt(self, token: String) -> Self
Set a static default JWT. Sugar over with_token_provider.
Sourcepub async fn call(&self, payload: Vec<u8>) -> Result<Vec<u8>>
pub async fn call(&self, payload: Vec<u8>) -> Result<Vec<u8>>
Send a request and return the verified, unwrapped response payload. Uses the client’s default JWT.
Sourcepub async fn call_for_service(
&self,
service_domain: &str,
payload: Vec<u8>,
) -> Result<Vec<u8>>
pub async fn call_for_service( &self, service_domain: &str, payload: Vec<u8>, ) -> Result<Vec<u8>>
Send a request bound to a canonical destination service. Generated
clients always use this path with their SERVICE_NAME.
Sourcepub async fn call_for_service_with_method(
&self,
service_domain: &str,
method_discriminator: u16,
payload: Vec<u8>,
) -> Result<Vec<u8>>
pub async fn call_for_service_with_method( &self, service_domain: &str, method_discriminator: u16, payload: Vec<u8>, ) -> Result<Vec<u8>>
Send a generated request with an explicit schema method commitment.
Sourcepub async fn call_streaming(
&self,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
) -> Result<Vec<u8>>
pub async fn call_streaming( &self, payload: Vec<u8>, ephemeral_pubkey: [u8; 32], ) -> Result<Vec<u8>>
Send a streaming request with ephemeral DH pubkey. Returns the verified, unwrapped response payload (typically StreamInfo). Uses the client’s default JWT.
Sourcepub async fn call_streaming_for_service(
&self,
service_domain: &str,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
) -> Result<Vec<u8>>
pub async fn call_streaming_for_service( &self, service_domain: &str, payload: Vec<u8>, ephemeral_pubkey: [u8; 32], ) -> Result<Vec<u8>>
Send a streaming setup request bound to a canonical destination.
Sourcepub async fn call_streaming_for_service_with_method(
&self,
service_domain: &str,
method_discriminator: u16,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
) -> Result<Vec<u8>>
pub async fn call_streaming_for_service_with_method( &self, service_domain: &str, method_discriminator: u16, payload: Vec<u8>, ephemeral_pubkey: [u8; 32], ) -> Result<Vec<u8>>
Send a generated streaming request with an explicit schema method commitment.
Sourcepub async fn call_streaming_identified_for_service(
&self,
service_domain: &str,
payload: Vec<u8>,
recipient: RecipientPublic,
) -> Result<Vec<u8>>
pub async fn call_streaming_identified_for_service( &self, service_domain: &str, payload: Vec<u8>, recipient: RecipientPublic, ) -> Result<Vec<u8>>
Send an identified stream setup using the pinned classical+ML-KEM
recipient. The caller retains the matching keypair and combines the
returned StreamInfo.kemCiphertexts with its accepted-current
[IdentifiedStreamBinding] before opening the stream.
Sourcepub async fn call_streaming_with_options(
&self,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
options: CallOptions,
) -> Result<Vec<u8>>
pub async fn call_streaming_with_options( &self, payload: Vec<u8>, ephemeral_pubkey: [u8; 32], options: CallOptions, ) -> Result<Vec<u8>>
Send a streaming request with per-call authentication options.
Uses options.jwt if provided, otherwise falls back to default_jwt.
Sourcepub async fn call_streaming_with_options_for_service(
&self,
service_domain: &str,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
options: CallOptions,
) -> Result<Vec<u8>>
pub async fn call_streaming_with_options_for_service( &self, service_domain: &str, payload: Vec<u8>, ephemeral_pubkey: [u8; 32], options: CallOptions, ) -> Result<Vec<u8>>
Send an option-bearing streaming request bound to a canonical destination.
Sourcepub async fn call_streaming_with_options_for_service_with_method(
&self,
service_domain: &str,
method_discriminator: u16,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
options: CallOptions,
) -> Result<Vec<u8>>
pub async fn call_streaming_with_options_for_service_with_method( &self, service_domain: &str, method_discriminator: u16, payload: Vec<u8>, ephemeral_pubkey: [u8; 32], options: CallOptions, ) -> Result<Vec<u8>>
Send an option-bearing generated streaming request bound to its service and method.
Sourcepub async fn call_with_options(
&self,
payload: Vec<u8>,
options: CallOptions,
) -> Result<Vec<u8>>
pub async fn call_with_options( &self, payload: Vec<u8>, options: CallOptions, ) -> Result<Vec<u8>>
Send a request with per-call authentication options.
Uses options.jwt if provided, otherwise falls back to default_jwt.
Includes options.delegated_bearer in the envelope for relay.
Sourcepub async fn call_with_options_for_service(
&self,
service_domain: &str,
payload: Vec<u8>,
options: CallOptions,
) -> Result<Vec<u8>>
pub async fn call_with_options_for_service( &self, service_domain: &str, payload: Vec<u8>, options: CallOptions, ) -> Result<Vec<u8>>
Send an option-bearing request bound to a canonical destination.
Sourcepub async fn call_with_options_for_service_with_method(
&self,
service_domain: &str,
method_discriminator: u16,
payload: Vec<u8>,
options: CallOptions,
) -> Result<Vec<u8>>
pub async fn call_with_options_for_service_with_method( &self, service_domain: &str, method_discriminator: u16, payload: Vec<u8>, options: CallOptions, ) -> Result<Vec<u8>>
Send an option-bearing generated request bound to its service and method.
Sourcepub async fn open_stream(&self, payload: Vec<u8>) -> Result<StreamHandleImpl<T>>
pub async fn open_stream(&self, payload: Vec<u8>) -> Result<StreamHandleImpl<T>>
Open a verified streaming subscription.
Generates an ephemeral keypair, sends the streaming request, performs ECDH + key derivation, subscribes to the data topic, opens the ctrl channel, and creates a verified StreamHandle.
All crypto happens in Rust — the caller just gets a handle that yields verified payloads.
Sourcepub async fn open_stream_for_service_with_method(
&self,
service_domain: &str,
method_discriminator: u16,
payload: Vec<u8>,
) -> Result<StreamHandleImpl<T>>
pub async fn open_stream_for_service_with_method( &self, service_domain: &str, method_discriminator: u16, payload: Vec<u8>, ) -> Result<StreamHandleImpl<T>>
Open a generated verified stream bound to its canonical service and method.
Sourcepub async fn open_stream_with_options(
&self,
payload: Vec<u8>,
options: CallOptions,
) -> Result<StreamHandleImpl<T>>
pub async fn open_stream_with_options( &self, payload: Vec<u8>, options: CallOptions, ) -> Result<StreamHandleImpl<T>>
Open a verified streaming subscription with per-call authentication options.
Same as open_stream but passes per-call JWT through the streaming
request envelope. Used by WASM client where JWT is set post-construction.
Sourcepub async fn open_stream_with_options_for_service_with_method(
&self,
service_domain: &str,
method_discriminator: u16,
payload: Vec<u8>,
options: CallOptions,
) -> Result<StreamHandleImpl<T>>
pub async fn open_stream_with_options_for_service_with_method( &self, service_domain: &str, method_discriminator: u16, payload: Vec<u8>, options: CallOptions, ) -> Result<StreamHandleImpl<T>>
Open an option-bearing generated stream bound to its canonical service and method.
Sourcepub async fn open_stream_from_info(
&self,
stream_info: StreamInfo,
client_secret: &[u8; 32],
client_pubkey: &[u8; 32],
) -> Result<StreamHandleImpl<T>>
pub async fn open_stream_from_info( &self, stream_info: StreamInfo, client_secret: &[u8; 32], client_pubkey: &[u8; 32], ) -> Result<StreamHandleImpl<T>>
Open a verified stream from pre-parsed StreamInfo + ephemeral keys.
Use when the streaming RPC was already sent (e.g., via dispatch) and you have the StreamInfo + ephemeral keypair. Skips the send step.
Trait Implementations§
Source§impl<S: Signer, T: Transport + 'static> RpcClient for RpcClientImpl<S, T>
Blanket impl: any RpcClientImpl<S, T> satisfies RpcClient.
impl<S: Signer, T: Transport + 'static> RpcClient for RpcClientImpl<S, T>
Blanket impl: any RpcClientImpl<S, T> satisfies RpcClient.
Source§fn call<'life0, 'async_trait>(
&'life0 self,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn call<'life0, 'async_trait>(
&'life0 self,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn call_for_service<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call_for_service<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn call_for_service_with_method<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
method_discriminator: u16,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call_for_service_with_method<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
method_discriminator: u16,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn call_with_options<'life0, 'async_trait>(
&'life0 self,
payload: Vec<u8>,
options: CallOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn call_with_options<'life0, 'async_trait>(
&'life0 self,
payload: Vec<u8>,
options: CallOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn call_with_options_for_service<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
payload: Vec<u8>,
options: CallOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call_with_options_for_service<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
payload: Vec<u8>,
options: CallOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call_with_options_for_service_with_method<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
method_discriminator: u16,
payload: Vec<u8>,
options: CallOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn call_streaming<'life0, 'async_trait>(
&'life0 self,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn call_streaming<'life0, 'async_trait>(
&'life0 self,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn call_streaming_for_service<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call_streaming_for_service<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call_streaming_with_options_for_service<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
options: CallOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn call_streaming_for_service_with_method<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
method_discriminator: u16,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call_streaming_for_service_with_method<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
method_discriminator: u16,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call_streaming_with_options_for_service_with_method<'life0, 'life1, 'async_trait>(
&'life0 self,
service_domain: &'life1 str,
method_discriminator: u16,
payload: Vec<u8>,
ephemeral_pubkey: [u8; 32],
options: CallOptions,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn open_stream<'life0, 'async_trait>(
&'life0 self,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn StreamHandle>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn open_stream<'life0, 'async_trait>(
&'life0 self,
payload: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn StreamHandle>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn open_stream_from_info<'life0, 'async_trait>(
&'life0 self,
stream_info: StreamInfo,
client_secret: [u8; 32],
client_pubkey: [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<Box<dyn StreamHandle>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn open_stream_from_info<'life0, 'async_trait>(
&'life0 self,
stream_info: StreamInfo,
client_secret: [u8; 32],
client_pubkey: [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<Box<dyn StreamHandle>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl<S, T> !Freeze for RpcClientImpl<S, T>
impl<S, T> !RefUnwindSafe for RpcClientImpl<S, T>
impl<S, T> Send for RpcClientImpl<S, T>
impl<S, T> Sync for RpcClientImpl<S, T>
impl<S, T> Unpin for RpcClientImpl<S, T>
impl<S, T> UnsafeUnpin for RpcClientImpl<S, T>where
S: UnsafeUnpin,
T: UnsafeUnpin,
impl<S, T> !UnwindSafe for RpcClientImpl<S, T>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more