# `Nous.CodeRuntime.Result`
[🔗](https://github.com/nyo16/nous/blob/v0.17.1/lib/nous/code_runtime/result.ex#L59)

What a program produced.

`value` is the program's return value, already decoded. `logs` are its output
lines in order. `error` is `nil` on success, otherwise a
`Nous.CodeRuntime.Failure`.

**`logs` are populated even when `error` is set.** A program that printed six
lines and then looped forever until the deadline has told you where it got to,
and throwing that away in favour of a bare `:timeout` is how a debuggable
failure becomes a mystery. Providers must stream output eagerly rather than
collecting it at the end, or a killed run loses everything it said.

# `t`

```elixir
@type t() :: %Nous.CodeRuntime.Result{
  error: Nous.CodeRuntime.Failure.t() | nil,
  logs: [String.t()],
  value: term()
}
```

# `failed`

```elixir
@spec failed(Nous.CodeRuntime.Failure.kind(), String.t(), [String.t()]) :: t()
```

A failed result, carrying whatever the program managed to say first.

# `ok`

```elixir
@spec ok(term(), [String.t()]) :: t()
```

A successful result.

# `success?`

```elixir
@spec success?(t()) :: boolean()
```

Whether the program produced a value.

## Examples

    iex> Nous.CodeRuntime.Result.ok(42) |> Nous.CodeRuntime.Result.success?()
    true

    iex> Nous.CodeRuntime.Result.failed(:timeout, "deadline") |> Nous.CodeRuntime.Result.success?()
    false

---

*Consult [api-reference.md](api-reference.md) for complete listing*
