Skip to content

Infer type parameters on NetworkBehaviourAction #3240

@thomaseizinger

Description

@thomaseizinger

Description

Currently, we expose multiple type parameters on NetworkBehaviourAction despite all of them being able to be inferred from the corresponding NetworkBehaviour type. However, we do also expose individual mapping functions for the in-event etc.

We could consolidate all those type parameters into one but that would require us to put a bound onto the struct definition. Trait bounds should ideally always only be applied to functionality (i.e. impl blocks). Applying them to struct or enum definition easily creeps through into layers where you don't actually want them.

My suggestion would be to remove all trait bounds from NetworkBehaviourAction and expose the types as they are. For the common case where the types are unmapped, we can expose a type alias that infers all of these types from a type that implements NetworkBehaviour.

Motivation

Current Implementation

Are you planning to do it yourself in a pull request?

Yes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions