Skip to main content

ErasedProcedure

Struct ErasedProcedure 

Source
pub struct ErasedProcedure<TCtx> {
    pub input_schema: Option<Box<dyn ErasedSchema>>,
    pub output_schema: Option<Box<dyn ErasedSchema>>,
    pub error_map: ErrorMap,
    pub route: Route,
    pub meta: Meta,
    /* private fields */
}
Expand description

Fully type-erased procedure. Only TCtx (= TBaseCtx) remains as generic.

This is what Router and transport integrations work with. TInput/TOutput/TError are captured inside the exec closure — deserialization and serialization happen internally.

Fields§

§input_schema: Option<Box<dyn ErasedSchema>>§output_schema: Option<Box<dyn ErasedSchema>>§error_map: ErrorMap§route: Route§meta: Meta

Implementations§

Source§

impl<TCtx> ErasedProcedure<TCtx>

Source

pub fn new( exec: impl Fn(TCtx, DynInput) -> ProcedureStream + Send + Sync + 'static, route: Route, meta: Meta, ) -> ErasedProcedure<TCtx>

Create a new procedure with the given execution closure.

Schemas and error_map default to None/default.

Source

pub fn with_input_schema( self, schema: impl ErasedSchema, ) -> ErasedProcedure<TCtx>

Set the input schema.

Source

pub fn with_input_schema_boxed( self, schema: Box<dyn ErasedSchema>, ) -> ErasedProcedure<TCtx>

Set the input schema from a boxed trait object.

Source

pub fn with_output_schema( self, schema: impl ErasedSchema, ) -> ErasedProcedure<TCtx>

Set the output schema.

Source

pub fn with_output_schema_boxed( self, schema: Box<dyn ErasedSchema>, ) -> ErasedProcedure<TCtx>

Set the output schema from a boxed trait object.

Source

pub fn with_error_map(self, error_map: ErrorMap) -> ErasedProcedure<TCtx>

Set the error map.

Source

pub fn exec(&self, ctx: TCtx, input: DynInput) -> ProcedureStream

Execute the procedure with type-erased input.

Wraps the call in catch_unwind to prevent handler panics from crashing the server. Panics are caught and returned as ProcedureError::Unwind.

Note: Only synchronous panics (during closure invocation) are caught. Panics inside the returned ProcedureStream’s async polling are NOT caught — this is a known limitation shared with rspc.

Trait Implementations§

Source§

impl<TCtx> Debug for ErasedProcedure<TCtx>

Source§

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

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

impl<TBaseCtx, TInput, TOutput, TError> From<Procedure<TBaseCtx, TInput, TOutput, TError>> for ErasedProcedure<TBaseCtx>
where TBaseCtx: Send + Sync + 'static,

Conversion to ErasedProcedure. Delegates to into_erased(), preserving all metadata.

Source§

fn from(proc: Procedure<TBaseCtx, TInput, TOutput, TError>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<TCtx> Freeze for ErasedProcedure<TCtx>

§

impl<TCtx> !RefUnwindSafe for ErasedProcedure<TCtx>

§

impl<TCtx> Send for ErasedProcedure<TCtx>

§

impl<TCtx> Sync for ErasedProcedure<TCtx>

§

impl<TCtx> Unpin for ErasedProcedure<TCtx>

§

impl<TCtx> UnsafeUnpin for ErasedProcedure<TCtx>

§

impl<TCtx> !UnwindSafe for ErasedProcedure<TCtx>

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

impl<T> Context for T
where T: Send + Sync + 'static,