pub struct DeferredDispatcher<D> { /* private fields */ }Expand description
A ConnectRPC dispatcher that can be initialized exactly once.
Tauri requires plugins that register URI schemes to be attached to the builder, but application services may depend on state created later in the app setup hook. Clone this dispatcher into the plugin’s service, then set the real dispatcher during setup.
Calls made before initialization are reported as unimplemented.
use connectrpc::{ConnectRpcService, Router};
use connectrpc_tauri::{DeferredDispatcher, serve};
let deferred = DeferredDispatcher::new();
fn plugin<R: tauri::Runtime>(
deferred: DeferredDispatcher<Router>,
) -> tauri::plugin::TauriPlugin<R> {
serve(ConnectRpcService::new(deferred))
}
let _service = ConnectRpcService::new(deferred.clone());
assert!(deferred.set(Router::new()).is_ok());Implementations§
Source§impl<D> DeferredDispatcher<D>
impl<D> DeferredDispatcher<D>
Sourcepub fn set(&self, dispatcher: D) -> Result<(), D>
pub fn set(&self, dispatcher: D) -> Result<(), D>
Sets the dispatcher used for all subsequent calls.
§Errors
Returns dispatcher unchanged if this instance was already initialized.
Sourcepub fn same_dispatcher(&self, other: &Self) -> bool
pub fn same_dispatcher(&self, other: &Self) -> bool
Returns true when both handles refer to the same deferred dispatcher.
Trait Implementations§
Source§impl<D> Clone for DeferredDispatcher<D>
impl<D> Clone for DeferredDispatcher<D>
Source§impl<D> Debug for DeferredDispatcher<D>
impl<D> Debug for DeferredDispatcher<D>
Source§impl<D> Default for DeferredDispatcher<D>
impl<D> Default for DeferredDispatcher<D>
Source§impl<D: Dispatcher> Dispatcher for DeferredDispatcher<D>
impl<D: Dispatcher> Dispatcher for DeferredDispatcher<D>
Source§fn lookup(&self, path: &str) -> Option<MethodDescriptor>
fn lookup(&self, path: &str) -> Option<MethodDescriptor>
Look up a method by its
service_name/method_name path. Read moreSource§fn call_unary(
&self,
path: &str,
context: RequestContext,
request: Payload,
format: CodecFormat,
) -> UnaryResult
fn call_unary( &self, path: &str, context: RequestContext, request: Payload, format: CodecFormat, ) -> UnaryResult
Dispatch a unary call. Read more
Source§fn call_server_streaming(
&self,
path: &str,
context: RequestContext,
request: Bytes,
format: CodecFormat,
) -> StreamingResult
fn call_server_streaming( &self, path: &str, context: RequestContext, request: Bytes, format: CodecFormat, ) -> StreamingResult
Dispatch a server-streaming call. Read more
Source§fn call_client_streaming(
&self,
path: &str,
context: RequestContext,
requests: RequestStream,
format: CodecFormat,
) -> UnaryResult
fn call_client_streaming( &self, path: &str, context: RequestContext, requests: RequestStream, format: CodecFormat, ) -> UnaryResult
Dispatch a client-streaming call. Read more
Source§fn call_bidi_streaming(
&self,
path: &str,
context: RequestContext,
requests: RequestStream,
format: CodecFormat,
) -> StreamingResult
fn call_bidi_streaming( &self, path: &str, context: RequestContext, requests: RequestStream, format: CodecFormat, ) -> StreamingResult
Dispatch a bidi-streaming call. Read more
Auto Trait Implementations§
impl<D> Freeze for DeferredDispatcher<D>
impl<D> RefUnwindSafe for DeferredDispatcher<D>
impl<D> Send for DeferredDispatcher<D>
impl<D> Sync for DeferredDispatcher<D>
impl<D> Unpin for DeferredDispatcher<D>
impl<D> UnsafeUnpin for DeferredDispatcher<D>
impl<D> UnwindSafe for DeferredDispatcher<D>
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