datex-core 0.0.13

The DATEX Core Rust implementation
Documentation
use crate::shared_values::{
    RemotePointerAddress, base_shared_value_container::BaseSharedValueContainer,
};

/// A shared container with an external pointer
#[derive(Debug)]
pub struct ExternalSharedContainer {
    value: BaseSharedValueContainer,
    /// Address of the remote pointer, can be a remote or builtin pointer address
    address: RemotePointerAddress,
}

impl ExternalSharedContainer {
    /// Create a new [ExternalSharedContainer] with a given [RemotePointerAddress].
    /// # Safety
    /// The caller must ensure that the [RemotePointerAddress] does not yet exist in the [SharedReferencesCache]
    pub unsafe fn new(
        shared_value_container: BaseSharedValueContainer,
        address: RemotePointerAddress,
    ) -> ExternalSharedContainer {
        ExternalSharedContainer {
            value: shared_value_container,
            address,
        }
    }
    pub fn value(&self) -> &BaseSharedValueContainer {
        &self.value
    }

    pub fn value_mut(&mut self) -> &mut BaseSharedValueContainer {
        &mut self.value
    }

    pub fn take_value(self) -> BaseSharedValueContainer {
        self.value
    }

    pub fn address(&self) -> &RemotePointerAddress {
        &self.address
    }
}