# inspect::TreeServer

`#include <service.h>`

[TreeServer](https://fuchsia.dev/reference/cpp/class/inspect/tree-server#classinspect_1_1_tree_server) is an implementation of the fuchsia.inspect.Tree protocol.

## Summary

Generally, it is not necessary to use this directly. See `https://fuchsia.dev/reference/cpp/class/inspect/component-inspector#classinspect_1_1_component_inspector`.

This class can be used directly if the client wishes to manage protocol registration details manually.

For an example of usage, see the constructor for `https://fuchsia.dev/reference/cpp/class/inspect/component-inspector#classinspect_1_1_component_inspector`.

### Inheritance

Inherits from: [fidl::WireServer\< fuchsia_inspect::Tree \>](https://fuchsia.dev/reference/cpp/other/singletonfidl/wire-server)

| ### Public static functions ||
|---|---|
| `https://fuchsia.dev/reference/cpp/class/inspect/tree-server#classinspect_1_1_tree_server_1abe9acdb08c8bc78277b435c21fa7c3db(std::variant< https://fuchsia.dev/reference/cpp/class/inspect/inspector#classinspect_1_1_inspector, https://fuchsia.dev/reference/cpp/class/zx/vmo#classzx_1_1vmo > data, https://fuchsia.dev/reference/cpp/struct/inspect/tree-handler-settings#structinspect_1_1_tree_handler_settings settings, async_dispatcher_t *dispatcher, https://fuchsia.dev/reference/cpp/other/singletonfidl/server-end#singletonfidl_1_1_server_end< fuchsia_inspect::Tree > && request)` | `void` Starts a new server. |

| ### Public functions ||
|---|---|
| `https://fuchsia.dev/reference/cpp/class/inspect/tree-server#classinspect_1_1_tree_server_1a521ae3229c1223de67295296e248617e(GetContentCompleter::Sync & completer) override` | `void` Get the VMO handle for the [Inspector](https://fuchsia.dev/reference/cpp/class/inspect/inspector#classinspect_1_1_inspector) handled by this server. |
| `https://fuchsia.dev/reference/cpp/class/inspect/tree-server#classinspect_1_1_tree_server_1a0e388ea43af86f7ddcb7088540071418(ListChildNamesRequestView request, ListChildNamesCompleter::Sync & completer) override` | `void` Start a server that furnishes the names of this Tree's children. |
| `https://fuchsia.dev/reference/cpp/class/inspect/tree-server#classinspect_1_1_tree_server_1ab30daac3e7c0a788a4792164978b8216(OpenChildRequestView request, OpenChildCompleter::Sync & completer) override` | `void` Start a server for handling the lazy child whose name is passed. |

## Public static functions

### StartSelfManagedServer

```c++
void StartSelfManagedServer(
  std::variant< Inspector, zx::vmo > data,
  TreeHandlerSettings settings,
  async_dispatcher_t *dispatcher,
  fidl::ServerEnd< fuchsia_inspect::Tree > && request
)
```
Starts a new server.

The implementation deletes itself during teardown after an unbind or else runs until component shutdown.

`data` is the Inspect data served over the connection.

The `https://fuchsia.dev/reference/cpp/class/inspect/inspector#classinspect_1_1_inspector` variant results in full-featured Inspect with lazy nodes and values.

The `https://fuchsia.dev/reference/cpp/class/zx/vmo#classzx_1_1vmo` variant will not serve lazy nodes/values. It will only serve the Inspect data in itself. The VMO may contain lazy nodes/values, but they will be ignored when snapshotting and parsing the data.

## Public functions

### GetContent

```c++
void GetContent(
  GetContentCompleter::Sync & completer
) override
```
Get the VMO handle for the [Inspector](https://fuchsia.dev/reference/cpp/class/inspect/inspector#classinspect_1_1_inspector) handled by this server.

### ListChildNames

```c++
void ListChildNames(
  ListChildNamesRequestView request,
  ListChildNamesCompleter::Sync & completer
) override
```
Start a server that furnishes the names of this Tree's children.

The names provided by the server this method starts are valid values to be passed to `OpenChild`.

### OpenChild

```c++
void OpenChild(
  OpenChildRequestView request,
  OpenChildCompleter::Sync & completer
) override
```
Start a server for handling the lazy child whose name is passed.