pub struct RouterBuilder { /* private fields */ }

Implementations§

source§

impl RouterBuilder

source

pub fn append_dyn( self, name: &'static str, dyn_handler: Box<dyn RpcHandlerWrapperTrait> ) -> Self

Add a dyn_handler to the router builder.

RouterBuilder::default().add_dyn("method_name", my_handler_fn.into_dyn());

Note: This is the preferred way to add handlers to the router, as it avoids monomorphization of the add function. The RouterInner also has a .add() as a convenience function to just pass the function. See RouterInner::add for more details.

source

pub fn append<F, T, P, R>(self, name: &'static str, handler: F) -> Self
where F: Handler<T, P, R> + Clone + Send + Sync + 'static, T: Send + Sync + 'static, P: Send + Sync + 'static, R: Send + Sync + 'static,

Add a route (name, handler function) to the builder

RouterBuilder::default().add("method_name", my_handler_fn);

Note: This is a convenient add function variant with generics, and there will be monomorphed versions of this function for each type passed. Use RouterInner::add_dyn to avoid this.

source

pub fn extend(self, other_builder: RouterBuilder) -> Self

Extends this builder by consuming another builder.

source

pub fn append_resource<T>(self, val: T) -> Self
where T: FromResources + Clone + Send + Sync + 'static,

source

pub fn extend_resources( self, resources_builder: Option<ResourcesBuilder> ) -> Self

If Some, will extends the current Base Resources with the content of this resources_builder. If None, just do nothing.

source

pub fn set_resources(self, resources_builder: ResourcesBuilder) -> Self

Resets the router’s resources with the contents of this ResourcesBuilder.

Ensure to call append_resource and/or .extend_resources afterwards if they operation needs to be included.

Note: .extend_resources(Option<ResourcesBuilder>) is the additive function typically used.

source

pub fn build(self) -> Router

Builds the RpcRouter from this builder. This is the typical usage, with the RpcRouter being encapsulated in an Arc, indicating it is designed for cloning and sharing across tasks/threads.

Trait Implementations§

source§

impl Debug for RouterBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for RouterBuilder

source§

fn default() -> RouterBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.

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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.