Skip to main content

SharedContainer

Enum SharedContainer 

Source
pub enum SharedContainer {
    Value(Rc<RefCell<SharedValueContainer>>),
    Type(Rc<RefCell<SharedTypeContainer>>),
}

Variants§

Implementations§

Source§

impl SharedContainer

Source

pub fn try_set_property<'a>( &self, source_id: TransceiverId, maybe_dif_update_data: Option<&DIFUpdateData>, key: impl Into<ValueKey<'a>>, val: ValueContainer, ) -> Result<(), AccessError>

Sets a property on the value if applicable (e.g. for maps)

Source

pub fn try_replace( &self, source_id: TransceiverId, maybe_dif_update_data: Option<&DIFUpdateData>, value: impl Into<ValueContainer>, ) -> Result<(), AccessError>

Sets a value on the reference if it is mutable and the type is compatible.

Source

pub fn try_append_value<'a>( &self, source_id: TransceiverId, maybe_dif_update_data: Option<&DIFUpdateData>, value: impl Into<ValueContainer>, ) -> Result<(), AccessError>

Pushes a value to the reference if it is a list.

Source

pub fn try_delete_property<'a>( &self, source_id: TransceiverId, maybe_dif_update_data: Option<&DIFUpdateData>, key: impl Into<ValueKey<'a>>, ) -> Result<(), AccessError>

Tries to delete a property from the reference if it is a map. Notifies observers if successful.

Source

pub fn try_clear(&self, source_id: TransceiverId) -> Result<(), AccessError>

Source

pub fn try_list_splice<'a>( &self, source_id: TransceiverId, maybe_dif_update_data: Option<&DIFUpdateData>, range: Range<u32>, items: Vec<ValueContainer>, ) -> Result<(), AccessError>

Source§

impl SharedContainer

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn unobserve_all(&self) -> Result<(), ObserverError>

Removes all observers from this reference. Returns an error if the reference is immutable.

Source

pub fn notify_observers(&self, dif: &DIFUpdate<'_>)

Notifies all observers of a change represented by the given DIFUpdate.

Source

pub fn has_observers(&self) -> bool

Check if there are any observers registered

Source§

impl SharedContainer

Source

pub fn pointer_address(&self) -> PointerAddress

Source

pub fn pointer(&self) -> Ref<'_, Pointer>

Source

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.

Source

pub fn try_boxed( value_container: ValueContainer, allowed_type: Option<TypeDefinition>, pointer: Pointer, mutability: SharedContainerMutability, ) -> Result<Self, SharedValueCreationError>

Creates a new shared value containing the given value container

Source

pub fn new_from_type( type_value: Type, pointer: Pointer, maybe_nominal_type_declaration: Option<NominalTypeDeclaration>, ) -> Self

Source

pub fn boxed_mut( value_container: ValueContainer, pointer: Pointer, ) -> Result<Self, SharedValueCreationError>

Source

pub fn boxed( value_container: impl Into<ValueContainer>, pointer: Pointer, ) -> Self

Source

pub fn collapse_reference_chain(&self) -> SharedContainer

Collapses the reference chain to most inner reference to which this reference points.

Source

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.

Source

pub fn value_container(&self) -> ValueContainer

Source

pub fn allowed_type(&self) -> TypeDefinition

Source

pub fn actual_type(&self) -> TypeDefinition

Source

pub fn is_type(&self) -> bool

Source

pub fn mutable_reference(&self) -> Option<Rc<RefCell<SharedValueContainer>>>

Returns a mutable reference to the ValueReference if this is a mutable ValueReference.

Source

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 SharedContainer

Getter for references

Source

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)

Trait Implementations§

Source§

impl Apply for SharedContainer

Source§

fn apply( &self, args: &[ValueContainer], ) -> Result<Option<ValueContainer>, ExecutionError>

Applies multiple ValueContainer arguments to self
Source§

fn apply_single( &self, arg: &ValueContainer, ) -> Result<Option<ValueContainer>, ExecutionError>

Applies a single ValueContainer argument to self
Source§

impl Clone for SharedContainer

Source§

fn clone(&self) -> SharedContainer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SharedContainer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for SharedContainer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<SharedTypeContainer> for SharedContainer

Source§

fn from(reference: SharedTypeContainer) -> Self

Converts to this type from the input type.
Source§

impl From<SharedValueContainer> for SharedContainer

Source§

fn from(reference: SharedValueContainer) -> Self

Converts to this type from the input type.
Source§

impl Hash for SharedContainer

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Identity for SharedContainer

Two references are identical if they point to the same data

Source§

fn identical(&self, other: &Self) -> bool

Check if two values are strictly identical (same pointer, same value, same type, same permissions).
Source§

impl PartialEq for SharedContainer

PartialEq corresponds to pointer equality / identity for Reference.

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralEq for SharedContainer

Source§

fn structural_eq(&self, other: &Self) -> bool

Check if two values are equal, ignoring the type.
Source§

impl ValueEq for SharedContainer

Source§

fn value_eq(&self, other: &Self) -> bool

Check if two values are exactly equal, including the type.
Source§

impl Eq for SharedContainer

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.