Skip to main content

Bindings

Struct Bindings 

Source
pub struct Bindings { /* private fields */ }
Expand description

Last-written widget property values; Ui::set_* runs only when a value actually changed.

writes and skipped count the observed sync calls, so tests can assert that an idle pass performs no widget writes.

Implementations§

Source§

impl Bindings

Source

pub fn new() -> Self

Creates an empty binding set (nothing written yet).

Source

pub fn writes(&self) -> usize

Widget writes performed since construction (or since the last Bindings::clear, which resets the counters too).

Source

pub fn skipped(&self) -> usize

Sync calls whose value was already current and were skipped.

Source

pub fn clear(&mut self)

Forgets every cached value so the next sync writes all widgets again.

Use this after changing widgets outside the bindings; ordinary model updates do not need it because changed values are detected per call.

Source

pub fn text<B: Backend>( &mut self, ui: &mut Ui<B>, id: WidgetId, value: &str, ) -> GuiResult<bool>

Syncs a widget’s text (label/button/input/…).

Returns true when the value was written, false when it was already current.

Source

pub fn checked<B: Backend>( &mut self, ui: &mut Ui<B>, id: WidgetId, value: bool, ) -> GuiResult<bool>

Syncs a check-capable widget’s checked state.

Source

pub fn value<B: Backend>( &mut self, ui: &mut Ui<B>, id: WidgetId, value: i32, ) -> GuiResult<bool>

Syncs a value-capable widget’s numeric value (slider/spin/progress).

Source

pub fn enabled<B: Backend>( &mut self, ui: &mut Ui<B>, id: WidgetId, value: bool, ) -> GuiResult<bool>

Syncs a widget’s enabled state.

Source

pub fn rows<B: Backend>( &mut self, ui: &mut Ui<B>, id: WidgetId, value: &[String], ) -> GuiResult<bool>

Memoized Ui::set_data_list_items: a list reloads only when its rows actually changed.

Trait Implementations§

Source§

impl Debug for Bindings

Source§

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

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

impl Default for Bindings

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.