# Ast

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-designer-core/struct-ast/

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

```rust
struct Ast
```

Lossless syntax index. Serialization is the owning document's source string,
rather than a pretty printer that would erase syntax trivia.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L125)

## Members

- [`root`](#function-root)
- [`roots`](#function-roots)
- [`node`](#function-node)
- [`nodes`](#function-nodes)
- [`elements`](#function-elements)
- [`nodes_in_source_order`](#function-nodes_in_source_order)
- [`nodes_with_name_scopes`](#function-nodes_with_name_scopes)
- [`subtree`](#function-subtree)
- [`element_children`](#function-element_children)
- [`find_name`](#function-find_name)
- [`name_scope`](#function-name_scope)
- [`node_at`](#function-node_at)
- [`element_at`](#function-element_at)
- [`is_descendant_of`](#function-is_descendant_of)
- [`namespaces`](#function-namespaces)

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

### root

```rust
fn root(self: &Self) -> NodeId
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L131)

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

### roots

```rust
fn roots(self: &Self) -> &[NodeId]
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L134)

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

### node

```rust
fn node(self: &Self, id: NodeId) -> Option<&Node>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L137)

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

### nodes

```rust
fn nodes(self: &Self) -> impl Iterator<Item = &Node>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L140)

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

### elements

```rust
fn elements(self: &Self) -> impl Iterator<Item = &Node>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L143)

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

### nodes_in_source_order

```rust
fn nodes_in_source_order(self: &Self) -> impl Iterator<Item = &Node>
```

Visit syntax nodes in lexical order, independently of stable node IDs.
Moving an element changes this order without changing its identity.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L148)

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

### nodes_with_name_scopes

```rust
fn nodes_with_name_scopes(self: &Self) -> impl Iterator<Item = (&Node, NodeId)>
```

Visit syntax nodes and their containing XAML name scopes in source order.
Scope propagation visits each node once instead of walking its ancestors
for every name or reference in a language-service indexing pass.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L154)

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

### subtree

```rust
fn subtree(self: &Self, root: NodeId) -> impl Iterator<Item = &Node>
```

Visit a node and all its syntax descendants in source order. An unknown
root produces an empty iterator; unrelated document nodes are not visited.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L171)

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

### element_children

```rust
fn element_children(self: &Self, parent: NodeId) -> Vec<NodeId>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L181)

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

### find_name

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L192)

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

### name_scope

```rust
fn name_scope(self: &Self, node: NodeId) -> NodeId
```

The containing XAML name scope. Template contents have their own scope;
a template's declaration belongs to its parent's scope. Unknown nodes and
top-level declarations use the document root.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L200)

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

### node_at

```rust
fn node_at(self: &Self, byte_offset: usize) -> Option<NodeId>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L213)

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

### element_at

```rust
fn element_at(self: &Self, byte_offset: usize) -> Option<NodeId>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L216)

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

### is_descendant_of

```rust
fn is_descendant_of(self: &Self, node: NodeId, ancestor: NodeId) -> bool
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L241)

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

### namespaces

```rust
fn namespaces(self: &Self, node: NodeId) -> BTreeMap<String, String>
```

Namespaces in scope at an element, nearest declaration wins.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Designer.Core/ast.rs#L252)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `DeserializeOwned`
- `Deserialize<'de>`
- `Clone`
- `Debug`
- `StructuralPartialEq`
- `PartialEq`
- `Eq`
- `Serialize`

## Availability

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