Table of Contents

Result<T, TE> Class

Definition

Namespace
Tyne
Assembly
Tyne.Core.dll

A result encapsulates either Ok(T) or Error(TE).

[JsonConverter(typeof(ResultJsonConverterFactory))]
public sealed class Result<T, TE> : IEquatable<Result<T, TE>>

Type Parameters

T

The type of value this result encapsulates.

TE

The type of error this result encapsulates.

Inheritance
Result<T, TE>
Implements

Methods

Equals(object?)

Determines whether the specified obj is a Result<T, TE>, and if so is equal to the current instance.

Equals(Result<T, TE>?)

Determines whether the specified other is equal to the current instance of the same type.

GetHashCode()

Returns a hash code for this instance.

ToString()

Returns a string that represents this instance.

TryUnwrap(out T?, out TE?)

Tries to unwrap this result.

Operators

operator ==(in Result<T, TE>?, in Result<T, TE>?)

Determines whether the left is equal to the right.

implicit operator Option<T>(in Result<T, TE>?)

Converts result into an Option<T>.

implicit operator Result<Unit, TE>(in Result<T, TE>)

Implicitly converts result into a Result<T, TE> of type Unit.

implicit operator Result<T, TE>(in T)

Implicitly converts value into an Ok(T) Result<T, TE>.

implicit operator Result<T, TE>(in TE)

Implicitly converts error into an Error(TE) Result<T, TE>.

operator !=(in Result<T, TE>?, in Result<T, TE>?)

Determines whether the left is not equal to the right.

Extension Methods

Apply<T, TE>(Result<T, TE>, Action<T>)
Apply<T, TE>(Result<T, TE>, Action<T>, Action<TE>)
Apply<T, TE>(Result<T, TE>, Func<T, Task>)
Apply<T, TE>(Result<T, TE>, Func<T, Task>, Func<TE, Task>)
Match<T, TE, TResult>(Result<T, TE>, Func<T, Task<TResult>>, Func<TE, Task<TResult>>)
Match<T, TE, TResult>(Result<T, TE>, Func<T, TResult>, Func<TE, TResult>)
OrDefault<T, TE>(Result<T, TE>)
Or<T, TE>(Result<T, TE>, Func<T>)
Or<T, TE>(Result<T, TE>, T)
Select<T, TE, TResult>(Result<T, TE>, Func<T, Task<TResult>>)
Select<T, TE, TResult>(Result<T, TE>, Func<T, TResult>)
ToOption<T, TE>(Result<T, TE>)
ToTask<T, TE>(Result<T, TE>)
ToValueTask<T, TE>(Result<T, TE>)

See Also