> This page is for NeMo Relay, version v0.10.0.
> For other versions, use one of these documentation indexes:
> - Latest (v0.10.0) (default): https://docs.nvidia.com/nemo/relay/latest/llms.txt
> - dev: https://docs.nvidia.com/nemo/relay/dev/llms.txt
> - v0.10.0: https://docs.nvidia.com/nemo/relay/v0.10.0/llms.txt
> - v0.9.4: https://docs.nvidia.com/nemo/relay/v0.9.4/llms.txt
> - v0.8.4: https://docs.nvidia.com/nemo/relay/v0.8.4/llms.txt
> - v0.7.3: https://docs.nvidia.com/nemo/relay/v0.7.3/llms.txt
> - v0.6.0: https://docs.nvidia.com/nemo/relay/v0.6.0/llms.txt
> - v0.5.0: https://docs.nvidia.com/nemo/relay/v0.5.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/relay/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/relay/_mcp/server.

# Struct Scope Guard

> RAII guard for a host scope opened by `PluginRuntime::scope` or `PluginRuntime::scope_at`.

Generated from `cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker`.

```rust
pub struct ScopeGuard<'a> { /* private fields */ }
```

RAII guard for a host scope opened by [`PluginRuntime::scope`](/reference/api/rust-library-reference/nemo-relay-plugin/struct-pluginruntime) or [`PluginRuntime::scope_at`](/reference/api/rust-library-reference/nemo-relay-plugin/struct-pluginruntime).

A guard may move between threads only while its scope stack is bound on the destination thread. Async middleware restores that binding around each poll; tasks created with `tokio::spawn` do not inherit it and must not own a guard.

## Implementations

### `impl<'a> ScopeGuard<'a>`

<pre />

#### `handle`

<pre />

Returns the active scope handle.

#### `close`

<pre />

Pops the scope with optional output and metadata.

#### `close_at`

<pre />

Pops the scope and records `ended_at` on its end event.

This is typed SDK access to the timestamp slot already carried by the native host's `scope_pop` function. The handle remains owned by this guard if the host rejects the close, so [`Drop`](https://doc.rust-lang.org/1.96.1/core/ops/drop/trait.Drop.html) can still attempt the ordinary cleanup path.

## Trait Implementations

### `impl Drop for ScopeGuard<'_>`

<pre />

#### `drop`

<pre />

### `impl Send for ScopeGuard<'_>`

<pre />