Skip to content

Use of internal API needed for blanket trait implementations #23

Closed
@zeenix

Description

For the serde Serializer/Deserializer of my crate, I need the types to not only implement the Serialize/Deserialize traits but also another very simple one but I still want to provide blanket implementation wherever possible. Since bitfields are common place for this format, I would like to provide this implementation:

impl<V> VariantValue for enumflags2::BitFlags<V>
where
     V: VariantValue ,
{
     fn signature() -> Signature<'static> { 
         V::signature()
     } 
}

but this won't work:

error[E0277]: the trait bound `V: enumflags2::_internal::RawBitFlags` is not satisfied
   --> zvariant/src/variant_value.rs:130:9
    |
130 | impl<V> VariantValue for enumflags2::BitFlags<V>
    |         ^^^^^^^^^^^^ the trait `enumflags2::_internal::RawBitFlags` is not implemented for `V`
131 | where
132 |     V: VariantValue,
    |                     - help: consider further restricting type parameter `V`: `, V: enumflags2::_internal::RawBitFlags`
    |
    = note: required by `enumflags2::BitFlags`

I can of course solve this by following the suggestion in the error but I feel uncomfortable using internal API that could break any time. Could you please consider making this public API?

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