datex-core 0.0.13

The DATEX Core Rust implementation
Documentation
use crate::{
    prelude::*,
    shared_values::{
        SharedContainerInner, SharedContainerMutability,
        SharedContainerOwnership,
        base_shared_value_container::{
            BaseSharedValueContainer,
            observers::{ObserverCallback, ObserverData, TransceiverId},
        },
    },
    types::type_definition::TypeDefinition,
    values::value_container::ValueContainer,
};
use core::cell::{Ref, RefMut};

pub trait SharedContainerCommon {
    /// Get the [SharedContainerMutability] of the container
    fn container_mutability(&self) -> SharedContainerMutability;

    /// Gets a [Ref] to the currently assigned [ValueContainer] of the shared container (not resolved recursively)
    fn value_container(&self) -> Ref<'_, ValueContainer>;

    /// Gets a [RefMut] to the currently assigned [ValueContainer] of the shared container (not resolved recursively)
    fn value_container_mut(&self) -> RefMut<'_, ValueContainer>;

    /// Gets a [Ref] to the currently assigned allowed [TypeDefinition] of the shared container (not resolved recursively)
    fn allowed_type(&self) -> Ref<'_, TypeDefinition>;

    /// Checks if the Rc in the shared container is currently borrowed mutably or immutably
    fn is_borrowed(&self) -> bool;

    /// Checks if the reference can be mutated by the local endpoint
    fn can_mutate(&self) -> bool;

    fn inner(&self) -> Ref<'_, SharedContainerInner>;
    fn inner_mut(&self) -> RefMut<'_, SharedContainerInner>;

    /// Gets a [Ref] to the currently assigned [BaseSharedValueContainer] of the shared container (not resolved recursively)
    fn base_shared_container(&self) -> Ref<'_, BaseSharedValueContainer>;

    /// Gets a [RefMut] to the currently assigned [BaseSharedValueContainer] of the shared container (not resolved recursively)
    fn base_shared_container_mut(&self)
    -> RefMut<'_, BaseSharedValueContainer>;

    /// Returns the [SharedContainerOwnership] of this shared container
    fn ownership(&self) -> SharedContainerOwnership;

    /// Returns a reference to the observer data of the shared container
    fn observer_data(&self) -> Ref<'_, ObserverData>;

    /// Returns a mutable reference to the observer data of the shared container
    fn observer_data_mut(&self) -> RefMut<'_, ObserverData>;

    /// Returns a list of all [ObserverCallback]s that are currently active for the given [TransceiverId]
    fn get_current_observers(
        &self,
        source_id: &TransceiverId,
    ) -> Vec<ObserverCallback> {
        self.observer_data().get_current_observers(source_id)
    }

    /// Returns true if the shared container is uninitialized (i.e., it has no value assigned yet)
    fn is_uninitialized(&self) -> bool;
}