Table of Contents

Class Result

Namespace
Badeend
Assembly
Badeend.Result.dll

Supporting methods for Result<TValue> and Result<TValue, TError>.

public static class Result
Inheritance
Result
Inherited Members

Methods

Error<TValue>(Error)

Create a failed basic result.

[Pure]
public static Result<TValue> Error<TValue>(Error error)

Parameters

error Error

Returns

Result<TValue>

Type Parameters

TValue

Error<TValue, TError>(TError)

Create a failed generic result.

[Pure]
public static Result<TValue, TError> Error<TValue, TError>(TError error)

Parameters

error TError

Returns

Result<TValue, TError>

Type Parameters

TValue
TError

GetErrorRefOrDefaultRef<TValue>(ref readonly Result<TValue>)

Attempt to get a readonly reference to the operation's error value. Returns a reference to Error's default value when the operation succeeded.

[Pure]
public static ref readonly Error GetErrorRefOrDefaultRef<TValue>(ref readonly Result<TValue> result)

Parameters

result Result<TValue>

Returns

Error

Type Parameters

TValue

GetErrorRefOrDefaultRef<TValue, TError>(ref readonly Result<TValue, TError>)

Attempt to get a readonly reference to the operation's error value. Returns a reference to TError's default value when the operation succeeded.

[Pure]
public static ref readonly TError GetErrorRefOrDefaultRef<TValue, TError>(ref readonly Result<TValue, TError> result)

Parameters

result Result<TValue, TError>

Returns

TError

Type Parameters

TValue
TError

GetUnderlyingErrorType(Type)

Returns the underlying TError type argument of the provided result type, or typeof(Badeend.Error) for the Result<TValue> shorthand result types.

Returns null if resultType is not a closed generic result type.

public static Type? GetUnderlyingErrorType(Type resultType)

Parameters

resultType Type

Returns

Type

Exceptions

ArgumentNullException

resultType is null.

GetUnderlyingValueType(Type)

Returns the underlying TValue type argument of the provided result type. Returns null if resultType is not a closed generic result type.

public static Type? GetUnderlyingValueType(Type resultType)

Parameters

resultType Type

Returns

Type

Exceptions

ArgumentNullException

resultType is null.

GetValueRefOrDefaultRef<TValue>(ref readonly Result<TValue>)

Attempt to get a readonly reference the operation's success value. Returns a reference to TValue's default value when the operation failed.

[Pure]
public static ref readonly TValue GetValueRefOrDefaultRef<TValue>(ref readonly Result<TValue> result)

Parameters

result Result<TValue>

Returns

TValue

Type Parameters

TValue

GetValueRefOrDefaultRef<TValue, TError>(ref readonly Result<TValue, TError>)

Attempt to get a readonly reference the operation's success value. Returns a reference to TValue's default value when the operation failed.

[Pure]
public static ref readonly TValue GetValueRefOrDefaultRef<TValue, TError>(ref readonly Result<TValue, TError> result)

Parameters

result Result<TValue, TError>

Returns

TValue

Type Parameters

TValue
TError

Success<TValue>(TValue)

Create a successful basic result.

[Pure]
public static Result<TValue> Success<TValue>(TValue value)

Parameters

value TValue

Returns

Result<TValue>

Type Parameters

TValue

Success<TValue, TError>(TValue)

Create a successful generic result.

[Pure]
public static Result<TValue, TError> Success<TValue, TError>(TValue value)

Parameters

value TValue

Returns

Result<TValue, TError>

Type Parameters

TValue
TError