Struct Result<TValue, TStatus>
A zero-allocation result type for hot-path methods.
TValue is the data; TStatus is a per-subsystem byte enum.
Convention: status value 0 = Success in all enums.
public readonly struct Result<TValue, TStatus> where TValue : unmanaged where TStatus : unmanaged, Enum
Type Parameters
TValueUnmanaged value returned on success; read only after checking IsSuccess.
TStatusUnmanaged byte-sized status enum where 0 denotes success.
- Inherited Members
Constructors
Result(TValue)
Creates a successful result with the specified value and default (zero) status.
public Result(TValue value)
Parameters
valueTValue
Result(TValue, TStatus)
Creates a result with both a value and an explicit status (e.g., Deleted with revision metadata).
public Result(TValue value, TStatus status)
Parameters
valueTValuestatusTStatus
Result(TStatus)
Creates a failure result with the specified status and default value.
public Result(TStatus status)
Parameters
statusTStatus
Fields
Status
The status code. Zero means success by convention.
public readonly TStatus Status
Field Value
- TStatus
Value
The value returned by the operation. Only meaningful when IsSuccess is true.
public readonly TValue Value
Field Value
- TValue
Properties
IsFailure
True when Status != 0.
public bool IsFailure { get; }
Property Value
IsSuccess
True when Status == 0 (Success by convention). No boxing — single byte comparison.
public bool IsSuccess { get; }