# ModelTypeSystem

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-build/type_system/struct-modeltypesystem/

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

```rust
struct ModelTypeSystem
```

The build-time type system.

The shells of the types of the models are created with the type system, in the order
of the models; a type costs its name until one of its members is asked for.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L71)

## Members

- [`new`](#function-new)
- [`as_type_system`](#function-as_type_system)
- [`models`](#function-models)
- [`get`](#function-get)
- [`type_of_model`](#function-type_of_model)
- [`types_of_model`](#function-types_of_model)
- [`resolve`](#function-resolve)
- [`is_cast`](#function-is_cast)
- [`nullable_of`](#function-nullable_of)
- [`attribute_type`](#function-attribute_type)
- [`project_attribute`](#function-project_attribute)

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

### new

```rust
fn new(models: Vec<AssemblyModel>) -> Rc<Self>
```

The type system over `models`: the model of a crate and the models of the crates
it is built on. Of two types with one full name the first is the type of the name.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L113)

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

### as_type_system

```rust
fn as_type_system(self: &Self) -> Rc<dyn IXamlTypeSystem>
```

This type system as a type system handle.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L195)

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

### models

```rust
fn models(self: &Self) -> &ModelSet
```

The models the type system is over.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L203)

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

### get

```rust
fn get(self: &Self, full_name: &str) -> Rc<dyn IXamlType>
```

The type named `full_name`, or the unknown pseudo type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L218)

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

### type_of_model

```rust
fn type_of_model(self: &Self, position: Position) -> Rc<dyn IXamlType>
```

The type the declaration at `position` of the models is (or is part of).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L226)

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

### types_of_model

```rust
fn types_of_model(self: &Self, model: usize) -> Vec<(&TypeModel, Rc<ModelType>)>
```

Every declaration of the model at `model`, with the type it is (or is part of).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L231)

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

### resolve

```rust
fn resolve(self: &Self, rust_type: &str) -> Rc<dyn IXamlType>
```

The type that values of the Rust type `rust_type` (normalised type text, in any
spelling of its paths and through any type alias of the models) are values of
(docs/porting/xaml.md, 9.5.2): a runtime library type, a class (for its handle and
its optional handle), a type with markup metadata (the optional form of a value
type is `System.Nullable<T>`), or else an opaque type that carries the text.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L654)

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

### is_cast

```rust
fn is_cast(self: &Self, from: &str, to: &str) -> bool
```

Whether a value of the Rust type `from` is a value of the Rust type `to`: the two
are one type, or a crate registers the cast between them.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L696)

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

### nullable_of

```rust
fn nullable_of(self: &Self, type_: &Rc<dyn IXamlType>) -> Option<Rc<dyn IXamlType>>
```

`System.Nullable<T>` of a value type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L702)

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

### attribute_type

```rust
fn attribute_type(self: &Self, name: &str) -> Rc<dyn IXamlType>
```

The type of the attribute a metadata attribute named `name` is projected to;
defined by the type system if no such type is declared.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L739)

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

### project_attribute

```rust
fn project_attribute(self: &Self, attribute: &AttributeModel) -> Rc<dyn IXamlCustomAttribute>
```

Projects an attribute of the model.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/type_system/model_type_system.rs#L747)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `IXamlTypeSystem`

## Availability

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