Struct TwoWayBinding

pub struct TwoWayBinding(/* private fields */);
Expand description

Two-way binding causes changes to either the source value or the target value to automatically update the other.

In a two-way binding the binding from the source to target works the same way as in a Binding. When the source value is modified, the value is written to the BindingTargetRuntime of the TwoWayBinding.

When anything other than the binding itself modifies the target value, the value is copied to the source. The value is copied to the source using set_property to write the property value.

Removing the binding does not erase the value that is written to the source.

Implementations§

§

impl TwoWayBinding

pub fn create<T>( source_path: impl AsRef<KanziStr>, source_property_type: &PropertyType<T>, source_field: PropertyField, ) -> Result<TwoWayBinding, Error>

Creates a two-way binding.

§Arguments
  • source_path - Path to source object.
  • source_property_type - Source property type from which to bind.
  • source_field - Field of the source property type from which to bind. Use PropertyField::Whole to bind to the whole property.

pub fn create_with_property<T>( source_path: impl AsRef<KanziStr>, source_property_type: &PropertyType<T>, ) -> Result<TwoWayBinding, Error>

Creates a two-way binding.

§Arguments
  • source_path - Path to source object.
  • source_property_type - Source property type from which to bind.

Methods from Deref<Target = AbstractBinding>§

pub fn as_ptr(&self) -> *mut AbstractBindingWrapper

pub fn get_native(&self) -> Result<NonNull<c_void>, Error>

Gets a pointer to the backing C++ instance.

pub fn add_processor( &self, binding_processor: &BindingProcessor, ) -> Result<(), Error>

Adds binding processor.

pub fn remove_processor( &self, binding_processor: &BindingProcessor, ) -> Result<(), Error>

Removes binding processor.

Trait Implementations§

§

impl Deref for TwoWayBinding

§

type Target = AbstractBinding

The resulting type after dereferencing.
§

fn deref(&self) -> &<TwoWayBinding as Deref>::Target

Dereferences the value.
§

impl Inherits<AbstractBinding> for TwoWayBinding

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

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
§

impl<T> AsAny for T
where T: 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Inherits<T> for T

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.