Result

sealed interface Result<TResult : ToolResult>(source)

Represents a sealed interface for results, which can either be a success or a failure.

This interface models the outcome of an operation, encapsulating both the result content and the status of the operation (successful or failed). It is parameterized by TResult, which must extend the ToolResult interface.

Parameters

TResult

The type of the result, constrained to types that implement ToolResult.

Inheritors

Types

Link copied to clipboard
data class Failure<TResult : ToolResult>(val message: String) : SafeTool.Result<TResult>

Represents a failed result encapsulating an error message.

Link copied to clipboard
data class Success<TResult : ToolResult>(val result: TResult, val content: String) : SafeTool.Result<TResult>

Represents a successful result of an operation, wrapping a specific tool result and its corresponding content.

Properties

Link copied to clipboard
abstract val content: String

Represents the content of the result within the sealed interface Result.

Functions

Link copied to clipboard

Casts the current object to a Failure type.

Link copied to clipboard

Casts the current instance of Result to a Success type if it is a successful result.

Link copied to clipboard
open fun isFailure(): Boolean

Determines whether the current instance represents a failure state.

Link copied to clipboard
open fun isSuccessful(): Boolean

Determines if the current result represents a successful operation.