Skip to main content

RpcClientImpl

Struct RpcClientImpl 

Source
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>

Source

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).

Source

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.

Source

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.

Source

pub fn with_pre_seal_guard(self, guard: Arc<dyn PreSealGuard>) -> Self

Source

pub fn with_browser_provisioning_binding( self, binding: BrowserRequestBinding, ) -> Result<Self>

Source

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.

Source

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.

Source

pub fn with_token_provider<F>(self, f: F) -> Self
where F: Fn() -> Option<String> + Send + Sync + 'static,

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).

Source

pub fn with_default_jwt(self, token: String) -> Self

Set a static default JWT. Sugar over with_token_provider.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn next_id(&self) -> u64

Get the next monotonically increasing request ID.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

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,

Send a request and return the verified response payload.
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,

Send a request bound to a canonical destination service.
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,

Send a generated request with an explicit canonical schema method id.
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,

Send a request with per-call authentication options. Read more
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,

Send an option-bearing request bound to a canonical destination.
Source§

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,

Send a streaming request with ephemeral DH pubkey.
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,

Send a streaming setup request bound to a canonical destination.
Source§

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,

Send a generated streaming request with an explicit schema method id.
Source§

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,

Open a verified streaming subscription.
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,

Open a verified stream from pre-parsed StreamInfo + ephemeral keys.
Source§

fn next_id(&self) -> u64

Get the next request ID.

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>
where S: Unpin, T: Unpin,

§

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> 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> MaybeSync for T
where T: Sync,