pub enum Reference {
ValueReference(Rc<RefCell<ValueReference>>),
TypeReference(Rc<RefCell<TypeReference>>),
}Variants§
ValueReference(Rc<RefCell<ValueReference>>)
TypeReference(Rc<RefCell<TypeReference>>)
Implementations§
Source§impl Reference
impl Reference
Sourcepub fn try_set_property<'a>(
&self,
source_id: TransceiverId,
dif_update_data_or_memory: impl Into<DIFUpdateDataOrMemory<'a>>,
key: impl Into<ValueKey<'a>>,
val: ValueContainer,
) -> Result<(), AccessError>
pub fn try_set_property<'a>( &self, source_id: TransceiverId, dif_update_data_or_memory: impl Into<DIFUpdateDataOrMemory<'a>>, key: impl Into<ValueKey<'a>>, val: ValueContainer, ) -> Result<(), AccessError>
Sets a property on the value if applicable (e.g. for maps)
Sourcepub fn try_replace<'a>(
&self,
source_id: TransceiverId,
dif_update_data_or_memory: impl Into<DIFUpdateDataOrMemory<'a>>,
value: impl Into<ValueContainer>,
) -> Result<(), AccessError>
pub fn try_replace<'a>( &self, source_id: TransceiverId, dif_update_data_or_memory: impl Into<DIFUpdateDataOrMemory<'a>>, value: impl Into<ValueContainer>, ) -> Result<(), AccessError>
Sets a value on the reference if it is mutable and the type is compatible.
Sourcepub fn try_append_value<'a>(
&self,
source_id: TransceiverId,
dif_update_data_or_memory: impl Into<DIFUpdateDataOrMemory<'a>>,
value: impl Into<ValueContainer>,
) -> Result<(), AccessError>
pub fn try_append_value<'a>( &self, source_id: TransceiverId, dif_update_data_or_memory: impl Into<DIFUpdateDataOrMemory<'a>>, value: impl Into<ValueContainer>, ) -> Result<(), AccessError>
Pushes a value to the reference if it is a list.
Sourcepub fn try_delete_property<'a>(
&self,
source_id: TransceiverId,
dif_update_data_or_memory: impl Into<DIFUpdateDataOrMemory<'a>>,
key: impl Into<ValueKey<'a>>,
) -> Result<(), AccessError>
pub fn try_delete_property<'a>( &self, source_id: TransceiverId, dif_update_data_or_memory: impl Into<DIFUpdateDataOrMemory<'a>>, key: impl Into<ValueKey<'a>>, ) -> Result<(), AccessError>
Tries to delete a property from the reference if it is a map. Notifies observers if successful.
pub fn try_clear(&self, source_id: TransceiverId) -> Result<(), AccessError>
pub fn try_list_splice<'a>( &self, source_id: TransceiverId, dif_update_data_or_memory: impl Into<DIFUpdateDataOrMemory<'a>>, range: Range<u32>, items: Vec<ValueContainer>, ) -> Result<(), AccessError>
Source§impl Reference
impl Reference
Sourcepub fn observe(&self, observer: Observer) -> Result<u32, ObserverError>
pub fn observe(&self, observer: Observer) -> Result<u32, ObserverError>
Adds an observer to this reference that will be notified on value changes. Returns an error if the reference is immutable or a type reference. The returned u32 is an observer ID that can be used to remove the observer later.
Sourcepub fn unobserve(&self, observer_id: u32) -> Result<(), ObserverError>
pub fn unobserve(&self, observer_id: u32) -> Result<(), ObserverError>
Removes an observer by its ID. Returns an error if the observer ID is not found or the reference is immutable.
Sourcepub fn update_observer_options(
&self,
observer_id: u32,
options: ObserveOptions,
) -> Result<(), ObserverError>
pub fn update_observer_options( &self, observer_id: u32, options: ObserveOptions, ) -> Result<(), ObserverError>
Updates the options for an existing observer by its ID. Returns an error if the observer ID is not found or the reference is immutable.
Sourcepub fn observers_ids(&self) -> Vec<u32>
pub fn observers_ids(&self) -> Vec<u32>
Returns a list of all observer IDs currently registered to this reference. A type reference or immutable reference will always return an empty list.
Sourcepub fn unobserve_all(&self) -> Result<(), ObserverError>
pub fn unobserve_all(&self) -> Result<(), ObserverError>
Removes all observers from this reference. Returns an error if the reference is immutable.
Sourcepub fn notify_observers(&self, dif: &DIFUpdate<'_>)
pub fn notify_observers(&self, dif: &DIFUpdate<'_>)
Notifies all observers of a change represented by the given DIFUpdate.
Sourcepub fn has_observers(&self) -> bool
pub fn has_observers(&self) -> bool
Check if there are any observers registered
Source§impl Reference
impl Reference
pub fn pointer_address(&self) -> Option<PointerAddress>
Sourcepub fn set_pointer_address(&self, pointer_address: PointerAddress)
pub fn set_pointer_address(&self, pointer_address: PointerAddress)
Sets the pointer address of the reference. Panics if the reference already has a pointer address.
Sourcepub fn is_mutable(&self) -> bool
pub fn is_mutable(&self) -> bool
Checks if the reference is mutable. A reference is mutable if it is a mutable ValueReference and all references in the chain are mutable. TypeReferences are always immutable. FIXME #284: Do we really need this? Probably we already collapse the ref and then change it’s value and perform the mutability check on the most inner ref.
Sourcepub fn try_new_from_value_container(
value_container: ValueContainer,
allowed_type: Option<TypeDefinition>,
maybe_pointer_id: Option<PointerAddress>,
mutability: ReferenceMutability,
) -> Result<Self, ReferenceCreationError>
pub fn try_new_from_value_container( value_container: ValueContainer, allowed_type: Option<TypeDefinition>, maybe_pointer_id: Option<PointerAddress>, mutability: ReferenceMutability, ) -> Result<Self, ReferenceCreationError>
Creates a new reference from a value container
pub fn new_from_type( type_value: Type, maybe_pointer_address: Option<PointerAddress>, maybe_nominal_type_declaration: Option<NominalTypeDeclaration>, ) -> Self
pub fn try_mut_from( value_container: ValueContainer, ) -> Result<Self, ReferenceCreationError>
Sourcepub fn collapse_reference_chain(&self) -> Reference
pub fn collapse_reference_chain(&self) -> Reference
Collapses the reference chain to most inner reference to which this reference points.
Sourcepub fn collapse_to_value(&self) -> Rc<RefCell<Value>>
pub fn collapse_to_value(&self) -> Rc<RefCell<Value>>
Converts a reference to its current value, collapsing any reference chains and converting type references to type values.
pub fn value_container(&self) -> ValueContainer
pub fn allowed_type(&self) -> TypeDefinition
pub fn actual_type(&self) -> TypeDefinition
pub fn is_type(&self) -> bool
Sourcepub fn mutable_reference(&self) -> Option<Rc<RefCell<ValueReference>>>
pub fn mutable_reference(&self) -> Option<Rc<RefCell<ValueReference>>>
Returns a mutable reference to the ValueReference if this is a mutable ValueReference.
Sourcepub fn set_value_container(
&self,
new_value_container: ValueContainer,
) -> Result<(), AssignmentError>
pub fn set_value_container( &self, new_value_container: ValueContainer, ) -> Result<(), AssignmentError>
Sets the value container of the reference if it is mutable. If the reference is immutable, an error is returned.
Source§impl Reference
Getter for references
impl Reference
Getter for references
Sourcepub fn try_get_property<'a>(
&self,
key: impl Into<ValueKey<'a>>,
) -> Result<ValueContainer, AccessError>
pub fn try_get_property<'a>( &self, key: impl Into<ValueKey<'a>>, ) -> Result<ValueContainer, AccessError>
Gets a property on the value if applicable (e.g. for map and structs)
Source§impl Reference
impl Reference
Sourcepub fn ensure_pointer_address(&self, memory: &RefCell<Memory>) -> PointerAddress
pub fn ensure_pointer_address(&self, memory: &RefCell<Memory>) -> PointerAddress
Returns the PointerAddress of this reference, if it has one. Otherwise, it registers the reference in the given memory and returns the newly assigned PointerAddress.
Trait Implementations§
Source§impl Apply for Reference
impl Apply for Reference
Source§fn apply(
&self,
args: &[ValueContainer],
) -> Result<Option<ValueContainer>, ExecutionError>
fn apply( &self, args: &[ValueContainer], ) -> Result<Option<ValueContainer>, ExecutionError>
Source§fn apply_single(
&self,
arg: &ValueContainer,
) -> Result<Option<ValueContainer>, ExecutionError>
fn apply_single( &self, arg: &ValueContainer, ) -> Result<Option<ValueContainer>, ExecutionError>
Source§impl From<TypeReference> for Reference
impl From<TypeReference> for Reference
Source§fn from(reference: TypeReference) -> Self
fn from(reference: TypeReference) -> Self
Source§impl From<ValueReference> for Reference
impl From<ValueReference> for Reference
Source§fn from(reference: ValueReference) -> Self
fn from(reference: ValueReference) -> Self
Source§impl PartialEq for Reference
PartialEq corresponds to pointer equality / identity for Reference.
impl PartialEq for Reference
PartialEq corresponds to pointer equality / identity for Reference.
Source§impl StructuralEq for Reference
impl StructuralEq for Reference
Source§fn structural_eq(&self, other: &Self) -> bool
fn structural_eq(&self, other: &Self) -> bool
impl Eq for Reference
Auto Trait Implementations§
impl Freeze for Reference
impl !RefUnwindSafe for Reference
impl !Send for Reference
impl !Sync for Reference
impl Unpin for Reference
impl !UnwindSafe for Reference
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more