mirror of
https://github.com/Start9Labs/rpc-toolkit.git
synced 2026-04-04 22:49:44 +00:00
default context for CustomDisplayFn
This commit is contained in:
@@ -30,7 +30,7 @@ pub trait HandlerExt: Handler + Sized {
|
|||||||
fn with_custom_display_fn<Context: IntoContext, F>(
|
fn with_custom_display_fn<Context: IntoContext, F>(
|
||||||
self,
|
self,
|
||||||
display: F,
|
display: F,
|
||||||
) -> CustomDisplayFn<Context, F, Self>
|
) -> CustomDisplayFn<F, Self, Context>
|
||||||
where
|
where
|
||||||
F: Fn(HandleArgs<Context, Self>, Self::Ok) -> Result<(), Self::Err>;
|
F: Fn(HandleArgs<Context, Self>, Self::Ok) -> Result<(), Self::Err>;
|
||||||
fn with_inherited<Params, InheritedParams, F>(
|
fn with_inherited<Params, InheritedParams, F>(
|
||||||
@@ -66,7 +66,7 @@ impl<T: Handler + Sized> HandlerExt for T {
|
|||||||
fn with_custom_display_fn<Context: IntoContext, F>(
|
fn with_custom_display_fn<Context: IntoContext, F>(
|
||||||
self,
|
self,
|
||||||
display: F,
|
display: F,
|
||||||
) -> CustomDisplayFn<Context, F, Self>
|
) -> CustomDisplayFn<F, Self, Context>
|
||||||
where
|
where
|
||||||
F: Fn(HandleArgs<Context, Self>, Self::Ok) -> Result<(), Self::Err>,
|
F: Fn(HandleArgs<Context, Self>, Self::Ok) -> Result<(), Self::Err>,
|
||||||
{
|
{
|
||||||
@@ -319,12 +319,12 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CustomDisplayFn<Context, F, H> {
|
pub struct CustomDisplayFn<F, H, Context = AnyContext> {
|
||||||
_phantom: PhantomData<Context>,
|
_phantom: PhantomData<Context>,
|
||||||
print: F,
|
print: F,
|
||||||
handler: H,
|
handler: H,
|
||||||
}
|
}
|
||||||
impl<Context, F: Clone, H: Clone> Clone for CustomDisplayFn<Context, F, H> {
|
impl<Context, F: Clone, H: Clone> Clone for CustomDisplayFn<F, H, Context> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
_phantom: PhantomData::new(),
|
_phantom: PhantomData::new(),
|
||||||
@@ -333,7 +333,7 @@ impl<Context, F: Clone, H: Clone> Clone for CustomDisplayFn<Context, F, H> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<Context, F: Debug, H: Debug> Debug for CustomDisplayFn<Context, F, H> {
|
impl<Context, F: Debug, H: Debug> Debug for CustomDisplayFn<F, H, Context> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.debug_struct("CustomDisplayFn")
|
f.debug_struct("CustomDisplayFn")
|
||||||
.field("print", &self.print)
|
.field("print", &self.print)
|
||||||
@@ -341,7 +341,7 @@ impl<Context, F: Debug, H: Debug> Debug for CustomDisplayFn<Context, F, H> {
|
|||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<Context, F, H> HandlerTypes for CustomDisplayFn<Context, F, H>
|
impl<F, H, Context> HandlerTypes for CustomDisplayFn<F, H, Context>
|
||||||
where
|
where
|
||||||
H: HandlerTypes,
|
H: HandlerTypes,
|
||||||
{
|
{
|
||||||
@@ -351,7 +351,7 @@ where
|
|||||||
type Err = H::Err;
|
type Err = H::Err;
|
||||||
}
|
}
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl<Context, F, H> Handler for CustomDisplayFn<Context, F, H>
|
impl<F, H, Context> Handler for CustomDisplayFn<F, H, Context>
|
||||||
where
|
where
|
||||||
Context: Send + Sync + 'static,
|
Context: Send + Sync + 'static,
|
||||||
H: Handler,
|
H: Handler,
|
||||||
@@ -414,7 +414,7 @@ where
|
|||||||
self.handler.method_from_dots(method, ctx_ty)
|
self.handler.method_from_dots(method, ctx_ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<Context, F, H> PrintCliResult for CustomDisplayFn<Context, F, H>
|
impl<F, H, Context> PrintCliResult for CustomDisplayFn<F, H, Context>
|
||||||
where
|
where
|
||||||
Context: IntoContext,
|
Context: IntoContext,
|
||||||
H: HandlerTypes,
|
H: HandlerTypes,
|
||||||
|
|||||||
Reference in New Issue
Block a user