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: MetaImplementations§
Source§impl<TCtx> ErasedProcedure<TCtx>
impl<TCtx> ErasedProcedure<TCtx>
Sourcepub fn new(
exec: impl Fn(TCtx, DynInput) -> ProcedureStream + Send + Sync + 'static,
route: Route,
meta: Meta,
) -> ErasedProcedure<TCtx>
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.
Sourcepub fn with_input_schema(
self,
schema: impl ErasedSchema,
) -> ErasedProcedure<TCtx>
pub fn with_input_schema( self, schema: impl ErasedSchema, ) -> ErasedProcedure<TCtx>
Set the input schema.
Sourcepub fn with_input_schema_boxed(
self,
schema: Box<dyn ErasedSchema>,
) -> ErasedProcedure<TCtx>
pub fn with_input_schema_boxed( self, schema: Box<dyn ErasedSchema>, ) -> ErasedProcedure<TCtx>
Set the input schema from a boxed trait object.
Sourcepub fn with_output_schema(
self,
schema: impl ErasedSchema,
) -> ErasedProcedure<TCtx>
pub fn with_output_schema( self, schema: impl ErasedSchema, ) -> ErasedProcedure<TCtx>
Set the output schema.
Sourcepub fn with_output_schema_boxed(
self,
schema: Box<dyn ErasedSchema>,
) -> ErasedProcedure<TCtx>
pub fn with_output_schema_boxed( self, schema: Box<dyn ErasedSchema>, ) -> ErasedProcedure<TCtx>
Set the output schema from a boxed trait object.
Sourcepub fn with_error_map(self, error_map: ErrorMap) -> ErasedProcedure<TCtx>
pub fn with_error_map(self, error_map: ErrorMap) -> ErasedProcedure<TCtx>
Set the error map.
Sourcepub fn exec(&self, ctx: TCtx, input: DynInput) -> ProcedureStream
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>
impl<TCtx> Debug for ErasedProcedure<TCtx>
Source§impl<TBaseCtx, TInput, TOutput, TError> From<Procedure<TBaseCtx, TInput, TOutput, TError>> for ErasedProcedure<TBaseCtx>
Conversion to ErasedProcedure. Delegates to into_erased(), preserving all metadata.
impl<TBaseCtx, TInput, TOutput, TError> From<Procedure<TBaseCtx, TInput, TOutput, TError>> for ErasedProcedure<TBaseCtx>
Conversion to ErasedProcedure. Delegates to into_erased(), preserving all metadata.