# INameScope

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/controls/trait-inamescope/

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

```rust
trait INameScope
```

Defines a name scope.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L66)

## Members

- [`try_register_value`](#function-try_register_value)
- [`register_value`](#function-register_value)
- [`find_value`](#function-find_value)
- [`find_value_async`](#function-find_value_async)
- [`register`](#function-register)
- [`try_register`](#function-try_register)
- [`find_async`](#function-find_async)
- [`find`](#function-find)
- [`complete`](#function-complete)
- [`is_completed`](#function-is_completed)
- [`attached_to`](#function-attached_to)
- [`detached_from`](#function-detached_from)

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

### try_register_value

```rust
fn try_register_value(self: &Self, name: &str, value: BoxedValue) -> Result<(), NameScopeValueError>
```

Registers any non-null object, retaining its identity. The value form
corresponds to the managed `object` parameter. Existing native-only
custom scopes can override this method to accept plain objects too.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L70)

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

### register_value

```rust
fn register_value(self: &Self, name: &str, value: BoxedValue)
```

Registers any object; panics on the same errors as `try_register_value`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L80)

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

### find_value

```rust
fn find_value(self: &Self, name: &str) -> Option<BoxedValue>
```

Finds any named object immediately, without traversing incomplete scopes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L87)

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

### find_value_async

```rust
fn find_value_async(self: &Self, name: &str) -> SynchronousCompletionAsyncResult<Option<BoxedValue>>
```

Finds any named object, completing synchronously on registration or completion.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L92)

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

### register

```rust
fn register(self: &Self, name: &str, element: Ref<FerroObject>)
```

Registers an element in the name scope. Panics if the scope is
completed or another element is registered with the name: see
`try_register` for the form that reports these
as errors.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L100)

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

### try_register

```rust
fn try_register(self: &Self, name: &str, element: Ref<FerroObject>) -> Result<(), NameScopeError>
```

Registers an element in the name scope, reporting a completed scope
and a name that another element is registered with as errors.
Registering an element again with its name does nothing.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L109)

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

### find_async

```rust
fn find_async(self: &Self, name: &str) -> SynchronousCompletionAsyncResult<Option<Ref<FerroObject>>>
```

Finds a named element in the name scope, waits for the scope to be
completely populated before returning `None`. Returned results always
complete synchronously.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L114)

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

### find

```rust
fn find(self: &Self, name: &str) -> Option<Ref<FerroObject>>
```

Finds a named element in the name scope, returns immediately, doesn't
traverse the name scope stack.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L118)

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

### complete

```rust
fn complete(self: &Self)
```

Marks the name scope as completed, no further registrations will be
allowed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L122)

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

### is_completed

```rust
fn is_completed(self: &Self) -> bool
```

Whether the name scope is completed, no further registrations are
allowed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L126)

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

### attached_to

```rust
fn attached_to(self: &Self, _owner: &Ref<FerroObject>)
```

The scope became the value of the attached `NameScope` property of
`owner`, which holds it from now on. Not a member of the managed
original: there the scope and the element hold each other and the
collector frees both; here the scope holds this one element weakly
(it finds it as long as it is alive). A scope that holds no elements
itself has nothing to do.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L134)

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

### detached_from

```rust
fn detached_from(self: &Self, _owner: &Ref<FerroObject>)
```

The scope is no longer the value of the attached `NameScope`
property of `owner`: it holds the element as every other again.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/i_name_scope.rs#L138)

## Trait implementations

- [`INameScope`](/docs/0.5.0/api/ferroui-base/controls/trait-inamescope/)

## Availability

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