# Decycler

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/media/fonts/tables/struct-decycler/

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

```rust
struct Decycler<T: Copy + Eq + Hash>
```

Tracks visited nodes to detect cycles in a graph (composite glyphs, paint
graphs, etc.). Uses a depth limit to prevent stack overflow during
recursive traversal.

The intended usage pattern is "one instance per traversal": rent an
instance from a pool at the start of a walk and return it when done.

`enter` reports cycle / depth-limit failures as errors.
Callers that traverse user-supplied data (e.g. font tables) should treat
the failure as "stop traversing this subgraph".

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/fonts/tables/decycler.rs#L92)

## Members

- [`new`](#function-new)
- [`enter`](#function-enter)
- [`current_depth`](#function-current_depth)
- [`max_depth`](#function-max_depth)
- [`reset`](#function-reset)

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

### new

```rust
fn new(max_depth: i32) -> Self
```

Creates a new decycler with the specified maximum depth.

Panics when `max_depth` is less than 1.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/fonts/tables/decycler.rs#L102)

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

### enter

```rust
fn enter(self: &Self, id: T) -> Result<CycleGuard<'_, T>, DecyclerException>
```

Attempts to enter a node with the given ID.
Returns a guard that exits the node when dropped.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/fonts/tables/decycler.rs#L110)

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

### current_depth

```rust
fn current_depth(self: &Self) -> i32
```

Returns the current traversal depth.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/fonts/tables/decycler.rs#L139)

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

### max_depth

```rust
fn max_depth(self: &Self) -> i32
```

Returns the maximum allowed traversal depth.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/fonts/tables/decycler.rs#L144)

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

### reset

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

Resets the decycler to its initial state, clearing all visited nodes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/fonts/tables/decycler.rs#L149)

## Trait implementations

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

## Availability

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