# BindingHooks

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/binding/bindings/struct-bindinghooks/

**struct** · [`ferroui-reactiveui`](/docs/0.5.0/api/ferroui-reactiveui/) · v0.5.0

```rust
struct BindingHooks
```

Lets a registered [`IPropertyBindingHook`](/docs/0.5.0/api/ferroui-reactiveui/binding/interfaces/trait-ipropertybindinghook/) inspect, or refuse, a binding as it is created
(`BindingHooks`).

A hook is consulted once per binding, before anything is wired, and a hook that returns `false`
cancels the binding. Hooks are registered in `AppLocator`, so the set is only known at run time:
it is read on first use and kept until `refresh`. `any` is the
guard a binding tests first, so that it builds the readers `should_bind`
takes only when a hook exists.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/binding_hooks.rs#L24)

## Members

- [`any`](#function-any)
- [`refresh`](#function-refresh)
- [`should_bind`](#function-should_bind)

<a id="function-any"></a>

### any

```rust
fn any() -> bool
```

Whether any hook was registered when the hooks were last read (`Any`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/binding_hooks.rs#L28)

<a id="function-refresh"></a>

### refresh

```rust
fn refresh()
```

Discards the cached hooks, so that the next use reads them from the locator again
(`Refresh`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/binding_hooks.rs#L34)

<a id="function-should_bind"></a>

### should_bind

```rust
fn should_bind(source: Option<&Rc<dyn Any>>, target: &Rc<dyn Any>, get_source_properties: &dyn Fn() -> BindingHookChanges, get_target_properties: &dyn Fn() -> BindingHookChanges, direction: BindingDirection) -> bool
```

Asks the registered hooks in turn whether this binding may be created, stopping at the
first refusal (`ShouldBind`): `true` when the binding may proceed, including when no hook
is registered.

`source` is the view model (`None` when there is none), `target` the view;
`get_source_properties` and `get_target_properties` read the current values along each path.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/bindings/binding_hooks.rs#L45)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
