use std::sync::Arc;

#[allow(deprecated)]
use crate::{prelude::Identity, DittoConfig};

/// A container for either a [`DittoConfig`] or an [`Identity`].
///
/// Used in the internal [`DittoFields`] to hold the user's initialization state.
#[allow(deprecated)]
pub(crate) enum ConfigOrIdentity {
    Config(DittoConfig),
    Identity(Arc<dyn Identity>),
}

#[allow(deprecated)]
impl ConfigOrIdentity {
    pub(crate) fn requires_offline_only_license_token(&self) -> bool {
        match self {
            ConfigOrIdentity::Config(config) => {
                matches!(
                    &config.connect,
                    crate::DittoConfigConnect::SmallPeersOnly { .. }
                )
            }
            ConfigOrIdentity::Identity(identity) => identity.requires_offline_only_license_token(),
        }
    }
}
