Pure trait library

Short version: Is there's such a thing as a "pure trait library" (well, 98% pure, there will be some enums as well) or is that kind of thing frowned upon?

I'm working on a system (realized as a binary executable) which has a reusable component (realized as a library) which in turn contains a trait which I only implement one of for my library, but I can easily imagine that others will want to implement their own backends (based on the same trait), which are "competitors" to my implementation (choice of word just to stress the point that they may not want to be forced to link against my library, because their implementation is completely separate -- they just share the same traits/interfaces).

I'm thinking about splitting out the trait (and associated enums) to a separate crate which has some kind of "-if" suffix to denote that it's an interface declaration. Is there some kind of prior art for this kind of thing?

1 Like

So, like serde

1 Like

Another example: https://github.com/RustCrypto/traits

1 Like

... and they provide tests in macro form. Neat!

1 Like