1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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;
}