use std::hash::Hash;

// TODO: FIXME once stable.
// #![feature(trait_alias)]
// trait Key = Clone + Eq + Hash;
// Currently unstable, see tracking issue:
// https://github.com/rust-lang/rust/issues/41517
//
// We can also remove the Send requirement by using feature flags
// once this is stable, so we don't need to unnecessarily require it.

/// PubSub trait which provides common actions.
pub trait PubSub<ClientKey: Clone + Eq + Hash, TopicKey: Clone + Eq + Hash, Data> {
    /// Remove a client from the Hive.
    fn drop_client(&self, id: &ClientKey) -> Result<(), String>;

    /// Remove a topic from the hive.
    fn drop_topic(&self, id: &TopicKey) -> Result<(), String>;

    /// Add a subscription to a topic.
    fn subscribe(&self, client: ClientKey, topic: TopicKey) -> Result<(), String>;

    /// Add several subscriptions to a topic.
    fn subscribe_multiple(&self, client: ClientKey, topics: Vec<TopicKey>) -> Result<(), String>;

    /// Remove a subscription to a topic.
    fn unsubscribe(&self, client: &ClientKey, topic: &TopicKey) -> Result<(), String>;

    /// Remove several subscriptions to a topic.
    fn unsubscribe_multiple(&self, client: &ClientKey, topics: &Vec<TopicKey>) -> Result<(), String>;

    /// Publish a message for a topic in the Hive.
    fn publish(&self, topic: &TopicKey, data: Data) -> Result<(), String>;
}
