PlatformResult<T> record

Namespace Runic.Platform in Runic.Platform 0.23.0

public abstract record PlatformResult<T> : IEquatable<PlatformResult<T>>

Inherits or implements IEquatable.

A service outcome. Cancellation is represented by an OperationCanceledException.

Remarks

The set of cases is closed: Success, Unavailable and Failed are the only ones for this major version.

Properties

Succeeded

public bool Succeeded { get; }

Whether this is a Success.

Methods

Match

public TResult Match<TResult>(Func<T, TResult> success, Func<PlatformResult<T>.Unavailable, TResult> unavailable, Func<PlatformResult<T>.Failed, TResult> failed)

Calls the function for this case and returns its result.

Type parameters

TResult

The type the functions return.

Parameters

success

Called with the value of a Success.

unavailable

Called with an Unavailable case.

failed

Called with a Failed case.

Returns

What the called function returned.

Exceptions

ArgumentNullException

A function is null.

TryGetValue

public bool TryGetValue(out T value)

Gets the value of a Success.

Parameters

value

The returned value when this is a Success; otherwise the default.

Returns

true for a Success; false for Unavailable and Failed.

Example

if ((await store.ReadAsync(key)).TryGetValue(out var secret)) { … }