TauRpcHandler

Trait TauRpcHandler 

Source
pub trait TauRpcHandler<R: Runtime>: Sized {
    const TRAIT_NAME: &'static str;
    const PATH_PREFIX: &'static str;
    const EXPORT_PATH: Option<&'static str>;

    // Required methods
    fn handle_incoming_request(self, invoke: Invoke<R>);
    fn spawn(self) -> Sender<Arc<Invoke<R>>>;
    fn args_map() -> String;
    fn collect_fn_types(type_map: &mut TypeCollection) -> Vec<Function>;
}
Expand description

A trait, which is automatically implemented by #[taurpc::procedures], that is used for handling incoming requests and the type generation.

Required Associated Constants§

Source

const TRAIT_NAME: &'static str

Source

const PATH_PREFIX: &'static str

This handler’s prefix in the TypeScript router.

Source

const EXPORT_PATH: Option<&'static str>

Bindings export path optionally specified by the user.

Required Methods§

Source

fn handle_incoming_request(self, invoke: Invoke<R>)

Handle a single incoming request

Source

fn spawn(self) -> Sender<Arc<Invoke<R>>>

Spawn a new tokio thread that listens for and handles incoming request through a tokio::broadcast::channel. This is used for when you have multiple handlers inside a router.

Source

fn args_map() -> String

Returns a json object containing the arguments for the methods. This is used on the frontend to ensure the arguments are send with their correct idents to the backend.

Source

fn collect_fn_types(type_map: &mut TypeCollection) -> Vec<Function>

Returns all of the functions for exporting, all referenced types will be added to type_map.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§