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
errorError
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
errorTError
Returns
- Result<TValue, TError>
Type Parameters
TValueTError
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
resultResult<TValue>
Returns
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
resultResult<TValue, TError>
Returns
- TError
Type Parameters
TValueTError
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
resultTypeType
Returns
Exceptions
- ArgumentNullException
resultTypeisnull.
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
resultTypeType
Returns
Exceptions
- ArgumentNullException
resultTypeisnull.
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
resultResult<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
resultResult<TValue, TError>
Returns
- TValue
Type Parameters
TValueTError
Success<TValue>(TValue)
Create a successful basic result.
[Pure]
public static Result<TValue> Success<TValue>(TValue value)
Parameters
valueTValue
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
valueTValue
Returns
- Result<TValue, TError>
Type Parameters
TValueTError