using AnthropicClient.Models;
///
/// Represents the result of an Anthropic API operation.
///
/// The type of the result value.
public class AnthropicResult
{
///
/// The value of the result.
///
public T Value { get; }
///
/// The error of the result.
///
public AnthropicError Error { get; }
///
/// Indicates whether the operation was successful.
///
public bool IsSuccess { get; }
///
/// The request ID of the operation.
///
public AnthropicHeaders Headers { get; }
///
/// Initializes a new instance of the class.
///
/// The value of the result.
/// The error of the result.
/// Indicates whether the operation was successful.
/// The Anthropic headers for the result.
/// A new instance of the class.
protected AnthropicResult(T value, AnthropicError error, bool isSuccess, AnthropicHeaders headers)
{
Value = value;
Error = error;
IsSuccess = isSuccess;
Headers = headers;
}
///
/// Creates a successful result.
///
/// The value of the result.
/// The Anthropic headers for the result.
/// A new instance of the class.
public static AnthropicResult Success(T value, AnthropicHeaders headers)
{
return new AnthropicResult(value, null!, true, headers);
}
///
/// Creates a failed result.
///
/// The error of the result.
/// The Anthropic headers for the result.
/// A new instance of the class.
public static AnthropicResult Failure(AnthropicError error, AnthropicHeaders headers)
{
return new AnthropicResult(default!, error, false, headers);
}
}