# FerroRuntimeXamlLoader

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-markup-xaml-loader/struct-ferroruntimexamlloader/

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

```rust
struct FerroRuntimeXamlLoader
```

Loads XAML at run time.

Every failure of a load (parsing, transforming, interpreting the
document, a member or markup extension that fails) is a
`XamlLoadError`: its message carries the line and position, its
inner error is the error of the compiler (`xamlx::exceptions::XamlError`).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L51)

## Members

- [`load`](#function-load)
- [`load_stream`](#function-load_stream)
- [`load_document`](#function-load_document)
- [`load_group`](#function-load_group)
- [`parse`](#function-parse)
- [`parse_as`](#function-parse_as)
- [`register_class_document`](#function-register_class_document)
- [`class_document`](#function-class_document)
- [`load_object`](#function-load_object)
- [`document_group`](#function-document_group)
- [`register`](#function-register)

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

### load

```rust
fn load(xaml: &str, local_assembly: Option<&'static MarkupAssembly>, root_instance: Option<BoxedValue>, uri: Option<url::Url>, design_mode: bool) -> Result<BoxedValue, XamlLoadError>
```

Loads XAML from a string.

* `local_assembly`: the default assembly for `clr-namespace:`.
* `root_instance`: the optional instance into which the XAML should
  be loaded.
* `uri`: the URL of the XAML being loaded, which relative references
  in it are resolved against.
* `design_mode`: whether the XAML is being loaded in design mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L62)

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

### load_stream

```rust
fn load_stream(stream: Box<dyn Read>, local_assembly: Option<&'static MarkupAssembly>, root_instance: Option<BoxedValue>, uri: Option<url::Url>, design_mode: bool) -> Result<BoxedValue, XamlLoadError>
```

Loads XAML from a stream of UTF-8 text.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L74)

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

### load_document

```rust
fn load_document(document: RuntimeXamlLoaderDocument, configuration: Option<RuntimeXamlLoaderConfiguration>) -> Result<BoxedValue, XamlLoadError>
```

Loads a document. Without a configuration the default one is used.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L89)

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

### load_group

```rust
fn load_group(documents: Vec<RuntimeXamlLoaderDocument>, configuration: Option<RuntimeXamlLoaderConfiguration>) -> Result<Vec<Option<BoxedValue>>, XamlLoadError>
```

Loads a group of documents that may refer to each other. Returns the
loaded object of each input document, in order.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L130)

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

### parse

```rust
fn parse(xaml: &str, local_assembly: Option<&'static MarkupAssembly>) -> Result<BoxedValue, XamlLoadError>
```

Parses XAML from a string.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L138)

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

### parse_as

```rust
fn parse_as<T: Clone + 'static>(xaml: &str, local_assembly: Option<&'static MarkupAssembly>) -> Result<T, XamlLoadError>
```

Parses XAML from a string to an object of type `T` (the handle type
of the object: `Ref<Border>`, `Rc<Style>`, ...). The cast of the
managed original: an object of another type is an invalid cast.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L145)

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

### register_class_document

```rust
fn register_class_document(class: &'static TypeInfo, uri: &str)
```

States that the markup of `class` (the class its root element names with
`x:Class`) is the document with the absolute URI `uri`, an asset of the crate.
Process-wide; a later registration for the same class replaces the earlier one.
See the module documentation.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L160)

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

### class_document

```rust
fn class_document(class: &'static TypeInfo) -> Option<String>
```

The URI of the document registered for `class` or, failing that, for the
nearest of its base classes that has one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L167)

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

### load_object

```rust
fn load_object(instance: &BoxedValue, service_provider: Option<&Rc<dyn IServiceProvider>>) -> Result<(), XamlLoadError>
```

Populates `instance` from the document registered for its class
(`register_class_document`): what
`FerroXamlLoader::load_object` does for a class without compiled markup.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L210)

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

### document_group

```rust
fn document_group(uri_text: &str, type_name: &str) -> Result<DocumentGroup, XamlLoadError>
```

The document at `uri_text` (of the class named `type_name`, for the
errors) with every document it includes, directly or not, that the
asset loader has, and the assembly of the document: the group the
document of a class is loaded (and compiled) as.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L247)

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

### register

```rust
fn register()
```

Makes the run-time loader the loader `FerroXamlLoader` falls back to
for documents without compiled markup (the `IRuntimeXamlLoader`
service). An application or a test host calls this once per
locator scope.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml.Loader/ferro_runtime_xaml_loader.rs#L291)

## 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`

## Availability

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