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(
&self,
source_id: TransceiverId,
key: ValueContainer,
val: ValueContainer,
memory: &RefCell<Memory>,
) -> Result<(), AccessError>
pub fn try_set_property( &self, source_id: TransceiverId, key: ValueContainer, val: ValueContainer, memory: &RefCell<Memory>, ) -> Result<(), AccessError>
Sets a property on the value if applicable (e.g. for maps)
Sourcepub fn try_set_text_property(
&self,
source_id: TransceiverId,
key: &str,
val: ValueContainer,
memory: &RefCell<Memory>,
) -> Result<(), AccessError>
pub fn try_set_text_property( &self, source_id: TransceiverId, key: &str, val: ValueContainer, memory: &RefCell<Memory>, ) -> Result<(), AccessError>
Sets a text property on the value if applicable (e.g. for structs)
pub fn try_set_numeric_property( &self, source_id: TransceiverId, index: u32, val: ValueContainer, memory: &RefCell<Memory>, ) -> Result<(), AccessError>
Sourcepub fn try_set_value<T: Into<ValueContainer>>(
&self,
source_id: TransceiverId,
value: T,
memory: &RefCell<Memory>,
) -> Result<(), AccessError>
pub fn try_set_value<T: Into<ValueContainer>>( &self, source_id: TransceiverId, value: T, memory: &RefCell<Memory>, ) -> Result<(), AccessError>
Sets a value on the reference if it is mutable and the type is compatible.
Sourcepub fn try_push_value<T: Into<ValueContainer>>(
&self,
source_id: TransceiverId,
value: T,
memory: &RefCell<Memory>,
) -> Result<(), AccessError>
pub fn try_push_value<T: Into<ValueContainer>>( &self, source_id: TransceiverId, value: T, memory: &RefCell<Memory>, ) -> Result<(), AccessError>
Pushes a value to the reference if it is a list.
Sourcepub fn try_delete_property(
&self,
source_id: TransceiverId,
key: ValueContainer,
memory: &RefCell<Memory>,
) -> Result<(), AccessError>
pub fn try_delete_property( &self, source_id: TransceiverId, key: ValueContainer, memory: &RefCell<Memory>, ) -> 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>
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
Sourcepub fn supports_clear(&self) -> bool
pub fn supports_clear(&self) -> bool
Checks if the reference supports clear operation
Sourcepub fn supports_property_access(&self) -> bool
pub fn supports_property_access(&self) -> bool
Checks if the reference has property access. This is true for maps, lists and text. For other types, this returns false. Note that this does not check if a specific property exists, only if property access is generally possible.
Sourcepub fn supports_text_property_access(&self) -> bool
pub fn supports_text_property_access(&self) -> bool
Checks if the reference has text property access. This is true for maps.
Sourcepub fn supports_numeric_property_access(&self) -> bool
pub fn supports_numeric_property_access(&self) -> bool
Checks if the reference has numeric property access. This is true for maps, lists and text.
Sourcepub fn supports_push(&self) -> bool
pub fn supports_push(&self) -> bool
Checks if the reference supports push operation
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<TypeContainer>,
maybe_pointer_id: Option<PointerAddress>,
mutability: ReferenceMutability,
) -> Result<Self, ReferenceCreationError>
pub fn try_new_from_value_container( value_container: ValueContainer, allowed_type: Option<TypeContainer>, 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 try_final_from(
value_container: ValueContainer,
) -> Result<Self, ReferenceCreationError>
pub fn try_final_from( value_container: ValueContainer, ) -> Result<Self, ReferenceCreationError>
Creates a final reference from a value container. If the value container is a reference, it must be a final reference, otherwise an error is returned. If the value container is a value, a final reference to that value is created.
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
Sourcepub fn upgrade_inner_combined_values_to_references(&self)
pub fn upgrade_inner_combined_values_to_references(&self)
upgrades all inner combined values (e.g. map properties) to references
Sourcepub fn bind_child(&self, child: ValueContainer) -> ValueContainer
pub fn bind_child(&self, child: ValueContainer) -> ValueContainer
Binds a child value to this reference, ensuring the child is a reference if it is a combined value
pub fn allowed_type(&self) -> TypeContainer
pub fn actual_type(&self) -> TypeContainer
pub fn is_type(&self) -> bool
Sourcepub fn non_final_reference(&self) -> Option<Rc<RefCell<ValueReference>>>
pub fn non_final_reference(&self) -> Option<Rc<RefCell<ValueReference>>>
Returns a non-final reference to the ValueReference if this is a non-final 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<T: Into<ValueContainer>>(
&self,
key: T,
) -> Result<ValueContainer, AccessError>
pub fn try_get_property<T: Into<ValueContainer>>( &self, key: T, ) -> Result<ValueContainer, AccessError>
Gets a property on the value if applicable (e.g. for map and structs)
Sourcepub fn try_get_text_property(
&self,
key: &str,
) -> Result<ValueContainer, AccessError>
pub fn try_get_text_property( &self, key: &str, ) -> Result<ValueContainer, AccessError>
Gets a text property from the value if applicable (e.g. for structs)
Sourcepub fn get_numeric_property(
&self,
index: u32,
) -> Result<ValueContainer, AccessError>
pub fn get_numeric_property( &self, index: u32, ) -> Result<ValueContainer, AccessError>
Gets a numeric property from the value if applicable (e.g. for lists and text)
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§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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);