dittolive-ditto 4.14.0

Ditto is a peer to peer cross-platform database that allows mobile, web, IoT and server apps to sync with or without an internet connection.
Documentation
use std::sync::Arc;

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.
pub(crate) enum ConfigOrIdentity {
    Config(DittoConfig),
    Identity(Arc<dyn Identity>),
}

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(),
        }
    }
}