# ObjectType

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

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

```rust
trait ObjectType: StaticType + Upcast<crate::FerroObject> + Sized
```

Implemented by every class.
## Safety

Implemented only by `ferro_class!` (and by hand for the root class).
Implementors guarantee that:

* `Self` is `#[repr(C)]`-compatible with `Parent` at offset zero, i.e. a
  pointer to `Self` is a valid pointer to every class in its ancestor
  chain;
* `VTable` likewise starts with `Parent::VTable` at offset zero;
* values of `Self` are only created through [`instantiate`](/docs/0.5.0/api/ferroui-base/function-instantiate/) (class structs
  have a private `base` field and `construct`-style constructors that are
  only meaningful inside `instantiate`).

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

## Members

- [`Parent`](#assoc_type-parent)
- [`IDENTITY`](#assoc_const-identity)
- [`register_class`](#function-register_class)

<a id="assoc_type-parent"></a>

### Parent

```rust
type Parent: ObjectType
```

The base class. The root class is its own parent.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/type_system.rs#L790)

<a id="assoc_const-identity"></a>

### IDENTITY

```rust
const IDENTITY: &'static TypeIdentity
```

The identity of the class (`TypeIdentity`): what `is::<Self>()`,
`cast::<Self>()` and `downcast_ref::<Self>()` compare. A type check names
this rather than `StaticType::TYPE`, so it does not keep the
initialisation, the constructor and the markup metadata of the class in
the executable (#612).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/type_system.rs#L806)

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

### register_class

```rust
fn register_class()
```

The static initialisation of the class. The first call on a thread,
after doing the same for the base class:

1. makes the type known by name (`TypeInfo::find`);
2. registers the handle type `Ref<Self>` and the interface handles the
   class declares (`ferro_class_info!`) with the untyped value
   conversions;
3. registers the properties of the class in declaration order
   (`ferro_properties!`);
4. runs the static constructor of the class
   (`ClassDefaults::static_constructor`).

Later calls only read a thread-local flag.

Generated by `ferro_class!`. Called by `instantiate`, so a class
that has an instance on the thread is initialised, and through
`TypeInfo::ensure_class_init` by property accessors and the property
registry, for classes that have none.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/type_system.rs#L829)

## Trait implementations

- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)

## Availability

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