Table of Contents

Struct HopLoadResult

Namespace
Trellis.Mediator
Assembly
Trellis.Mediator.dll

Result of loading a single related resource at one ID during a hop walk.

public readonly struct HopLoadResult
Inherited Members

Remarks

HopLoadResult uses an explicit success flag rather than inferring success from the presence of an error. The default instance is a failure (with a sentinel Error) so a misconfigured hop loader cannot accidentally produce a "successful" result carrying null as the loaded value, which would bypass the empty-list / failed-load short-circuits in ResourceAuthorizationViaBehavior<TMessage, TLeaf, TOwner, TResponse>.

Properties

Error

Gets the loader's error when failed or uninitialized; null when successful.

public Error? Error { get; }

Property Value

Error

IsSuccess

Gets a value indicating whether the load succeeded. false for default(HopLoadResult) so a misconfigured hop loader cannot accidentally pass a null value through the pipeline.

public bool IsSuccess { get; }

Property Value

bool

Value

Gets the loaded value when successful; null when failed.

public object? Value { get; }

Property Value

object

Methods

Failure(Error)

Creates a failure result carrying the loader's error.

public static HopLoadResult Failure(Error error)

Parameters

error Error

The loader's error. Must not be null.

Returns

HopLoadResult

Exceptions

ArgumentNullException

Thrown when error is null.

Success(object)

Creates a success result carrying the loaded value.

public static HopLoadResult Success(object value)

Parameters

value object

The loaded resource. Must not be null.

Returns

HopLoadResult

Exceptions

ArgumentNullException

Thrown when value is null.