mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add AnyNodeTypes type (#9034)
This commit is contained in:
@ -26,6 +26,32 @@ pub trait NodeTypes: Send + Sync + Unpin + 'static {
|
||||
type Engine: EngineTypes;
|
||||
}
|
||||
|
||||
/// A [`NodeTypes`] type builder
|
||||
#[derive(Default, Debug)]
|
||||
pub struct AnyNodeTypes<P = (), E = ()>(PhantomData<P>, PhantomData<E>);
|
||||
|
||||
impl<P, E> AnyNodeTypes<P, E> {
|
||||
/// Sets the `Primitives` associated type.
|
||||
pub const fn primitives<T>(self) -> AnyNodeTypes<T, E> {
|
||||
AnyNodeTypes::<T, E>(PhantomData::<T>, PhantomData::<E>)
|
||||
}
|
||||
|
||||
/// Sets the `Engine` associated type.
|
||||
pub const fn engine<T>(self) -> AnyNodeTypes<P, T> {
|
||||
AnyNodeTypes::<P, T>(PhantomData::<P>, PhantomData::<T>)
|
||||
}
|
||||
}
|
||||
|
||||
impl<P, E> NodeTypes for AnyNodeTypes<P, E>
|
||||
where
|
||||
P: NodePrimitives + Send + Sync + Unpin + 'static,
|
||||
E: EngineTypes + Send + Sync + Unpin + 'static,
|
||||
{
|
||||
type Primitives = P;
|
||||
|
||||
type Engine = E;
|
||||
}
|
||||
|
||||
/// A helper trait that is downstream of the [`NodeTypes`] trait and adds stateful components to the
|
||||
/// node.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user