Skip to main content

Builder

Struct Builder 

Source
pub struct Builder<S = ()> { /* private fields */ }
Available on crate feature rpc only.
Expand description

A Router being assembled.

S is the state the next handlers get, () until with_state is called.

Implementations§

Source§

impl<S> Builder<S>

Source

pub fn with_state<S2>(self, state: S2) -> Builder<S2>

Gives the next handlers state.

Source

pub fn handle<H, Args, P>(self, handler: H) -> Self
where H: Handler<Args, S, Request = P> + Send + Sync + 'static, P: DeserializeOwned + Procedure, P::Output: IntoReply, H::Return: Replies<<P::Output as IntoReply>::Reply, P::Error>, S: Clone + Send + Sync + 'static,

Replies to P with handler.

Source

pub fn handle_with<S2, H, Args, P>(self, state: S2, handler: H) -> Self
where H: Handler<Args, S2, Request = P> + Send + Sync + 'static, P: DeserializeOwned + Procedure, P::Output: IntoReply, H::Return: Replies<<P::Output as IntoReply>::Reply, P::Error>, S2: Clone + Send + Sync + 'static,

Replies to P with handler, which gets its own state.

Source

pub fn build(self) -> Result<Router, BuildError>

A router with one handler for each procedure.

§Errors

Every procedure and handler that don’t pair up.

Trait Implementations§

Source§

impl<S: Debug> Debug for Builder<S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Builder<S>
where S: Freeze,

§

impl<S = ()> !RefUnwindSafe for Builder<S>

§

impl<S> Send for Builder<S>
where S: Send,

§

impl<S> Sync for Builder<S>
where S: Sync,

§

impl<S> Unpin for Builder<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Builder<S>
where S: UnsafeUnpin,

§

impl<S = ()> !UnwindSafe for Builder<S>

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

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.