Skip to content

Example of dispatching on an interface #59

@csvance

Description

@csvance

This package has been quite helpful to test my interfaces that exist within a standard type hierarchy. Ie I have a top level abstract type the interface is defined on, then concrete types that inherit the abstract type and implement the interface. To dispatch on this I can just dispatch on the top level abstract type just like I would without Interfaces.jl. But it's not clear to me exactly how interfaces can be dispatched on outside of this. I see there are some functions inside the package like implemented_trait which produces a value:

julia> Interfaces.implemented_trait(MMISpineInterpolation.SpineInterpolatorInterface, SpineInterpolator)
Interfaces.Implemented{MMISpineInterpolation.SpineInterpolatorInterface}()

Presumably I can dispatch on this somehow even if my types do not inherit the abstract type my interface was defined on. But it's not clear to me what expression/syntax I need to check where a type T in a method declaration implements an interface. I have tried many different approaches, but I've been spinning my wheels for a few hours now and not making progress.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions