Skip to main content

SyncHandler

Struct SyncHandler 

Source
pub struct SyncHandler<Req, State, Res> {
    pub name: &'static str,
    pub module_name: &'static str,
    /* private fields */
}
Expand description

Type-erased synchronous handler wrapper.

Uses raw pointers and monomorphized function pointers to achieve type erasure without requiring 'static bounds on Req, State, Res, or the handler’s type parameter T. It gives up the async nature of Handler (its future is always Ready), in exchange boxing nothing per call and enabling the dual-state trick (WithSubState).

The caller is responsible for ensuring soundness.

Fields§

§name: &'static str

The handler’s name. It is often function name.

§module_name: &'static str

The module the handler was registered from. It is often produced by module_path!().

Implementations§

Source§

impl<Req, State, Res> SyncHandler<Req, State, Res>
where Req: Send, State: Send, Res: Send,

Source

pub fn new<T, H: Handler<T, Req, State, Res, Future = Ready<Option<Res>>>>( priority: u8, name: &'static str, module_name: &'static str, handler: H, ) -> Self

Create a synchronous handler.

Trait Implementations§

Source§

impl<Req, SubState, Target, Res> Call<Req, Target, Res> for SyncHandler<Req, SubState, Res>
where Req: Send + 'static, SubState: Send + 'static, Target: Send + 'static + WithSubState<SubState>, Res: Send + Mul<Output = Res> + 'static,

Source§

fn call( &self, bundle: Bundle<Req, Target, Res>, ) -> Pin<Box<dyn Future<Output = Bundle<Req, Target, Res>> + Send>>

Call the handler, returning the updated bundle.
Source§

fn priority(&self) -> u8

The handler’s priority, used to sort the chain.
Source§

impl<Req, State, Res> Clone for SyncHandler<Req, State, Res>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Req, State, Res> Drop for SyncHandler<Req, State, Res>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<Req, State, Res> Send for SyncHandler<Req, State, Res>

Safety: the stored handler satisfies Send + Sync via the Handler trait bound.

Source§

impl<Req, State, Res> Sync for SyncHandler<Req, State, Res>

Safety: the stored handler satisfies Send + Sync via the Handler trait bound.

Auto Trait Implementations§

§

impl<Req, State, Res> Freeze for SyncHandler<Req, State, Res>
where unsafe fn(*const (), &mut Bundle<Req, State, Res>) -> Option<Res>: Freeze,

§

impl<Req, State, Res> RefUnwindSafe for SyncHandler<Req, State, Res>
where unsafe fn(*const (), &mut Bundle<Req, State, Res>) -> Option<Res>: RefUnwindSafe,

§

impl<Req, State, Res> Unpin for SyncHandler<Req, State, Res>
where unsafe fn(*const (), &mut Bundle<Req, State, Res>) -> Option<Res>: Unpin,

§

impl<Req, State, Res> UnsafeUnpin for SyncHandler<Req, State, Res>
where unsafe fn(*const (), &mut Bundle<Req, State, Res>) -> Option<Res>: UnsafeUnpin,

§

impl<Req, State, Res> UnwindSafe for SyncHandler<Req, State, Res>
where unsafe fn(*const (), &mut Bundle<Req, State, Res>) -> Option<Res>: UnwindSafe,

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> CloneAny for T
where T: Any + Clone,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoResponse<T> for T
where T: Send,

Source§

fn into_response(self) -> T

Convert this value into a response.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubState<T> for T