You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, context traits containing sub-contexts, such as HasRuntime and HasRelayTypes, require the sub-contexts such as Self::Runtime, Self::SrcChain, and Self::DstChain to have the same Error associated type as Self::Error. This was done initially for easier understanding of the code.
However, it can be restrictive to require all contexts to share the same concrete error type, especially if the concrete contexts are defined in different crates. As an example, to workaround having a common Error type, the concrete runtime context TokioRuntimeContext is parameterized with a generic Error type, so that it can set its Error associated type to be the same as the Error type in the concrete chain or relay contexts.
A better design would be to allow each contexts to have their own abstract Error types, and require injection functions to inject errors into the parent context. For example, the HasRuntime trait can be redefined as follows:
When the parent context calls any methods from the sub-context, they can then use Self::inject_error to inject error types like Self::Runtime::Error into Self::Error.
For Admin Use
Not duplicate issue
Appropriate labels applied
Appropriate milestone (priority) applied
Appropriate contributors tagged
Contributor assigned/self-assigned
The text was updated successfully, but these errors were encountered:
Summary
Currently, context traits containing sub-contexts, such as
HasRuntime
andHasRelayTypes
, require the sub-contexts such asSelf::Runtime
,Self::SrcChain
, andSelf::DstChain
to have the sameError
associated type asSelf::Error
. This was done initially for easier understanding of the code.However, it can be restrictive to require all contexts to share the same concrete error type, especially if the concrete contexts are defined in different crates. As an example, to workaround having a common
Error
type, the concrete runtime contextTokioRuntimeContext
is parameterized with a genericError
type, so that it can set itsError
associated type to be the same as theError
type in the concrete chain or relay contexts.A better design would be to allow each contexts to have their own abstract
Error
types, and require injection functions to inject errors into the parent context. For example, theHasRuntime
trait can be redefined as follows:When the parent context calls any methods from the sub-context, they can then use
Self::inject_error
to inject error types likeSelf::Runtime::Error
intoSelf::Error
.For Admin Use
The text was updated successfully, but these errors were encountered: