Class MutationResult<TState>
Represents the outcome of applying a mutation to a state. Always contains a trace of changes, even if the mutation fails.
Implements
Inherited Members
Namespace: ModularityKit.Mutator.Abstractions.Results
Assembly: ModularityKit.Mutator.dll
Syntax
public sealed record MutationResult<TState> : IEquatable<MutationResult<TState>>
Type Parameters
| Name | Description |
|---|---|
| TState | The type of the state being mutated. |
Properties
| Edit this page View SourceChanges
The set of changes describing what exactly was modified during the mutation. Always populated, even on failure.
Declaration
public ChangeSet Changes { get; init; }
Property Value
| Type | Description |
|---|---|
| ChangeSet |
CompletedAt
Timestamp indicating when the mutation completed.
Declaration
public DateTimeOffset CompletedAt { get; init; }
Property Value
| Type | Description |
|---|---|
| DateTimeOffset |
Exception
Exception thrown during mutation, if any, for diagnostic purposes.
Declaration
public Exception? Exception { get; init; }
Property Value
| Type | Description |
|---|---|
| Exception |
IsSuccess
Indicates whether the mutation was successfully applied.
Declaration
public bool IsSuccess { get; init; }
Property Value
| Type | Description |
|---|---|
| bool |
Metrics
Metrics related to the execution of the mutation (e.g., duration, performance counters).
Declaration
public MutationMetrics Metrics { get; init; }
Property Value
| Type | Description |
|---|---|
| MutationMetrics |
NewState
The new state after mutation, if successful; otherwise null.
Declaration
public TState? NewState { get; init; }
Property Value
| Type | Description |
|---|---|
| TState |
PolicyDecisions
Decisions from policy evaluation that influenced the mutation outcome.
Declaration
public IReadOnlyList<PolicyDecision> PolicyDecisions { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<PolicyDecision> |
SideEffects
Side effects produced during the mutation.
Declaration
public IReadOnlyList<SideEffect> SideEffects { get; init; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<SideEffect> |
ValidationResult
Result of validation checks performed during mutation.
Declaration
public ValidationResult ValidationResult { get; init; }
Property Value
| Type | Description |
|---|---|
| ValidationResult |
Methods
| Edit this page View SourceFailure(ValidationResult)
Creates a failed mutation result due to validation errors.
Declaration
public static MutationResult<TState> Failure(ValidationResult validation)
Parameters
| Type | Name | Description |
|---|---|---|
| ValidationResult | validation | The validation result explaining the failure. |
Returns
| Type | Description |
|---|---|
| MutationResult<TState> | A MutationResult<TState> representing failure. |
PolicyBlocked(PolicyDecision)
Creates a failed mutation result due to policy enforcement.
Declaration
public static MutationResult<TState> PolicyBlocked(PolicyDecision decision)
Parameters
| Type | Name | Description |
|---|---|---|
| PolicyDecision | decision | The policy decision that blocked the mutation. |
Returns
| Type | Description |
|---|---|
| MutationResult<TState> | A MutationResult<TState> representing a policy-blocked mutation. |
Success(TState, ChangeSet, IReadOnlyList<SideEffect>?)
Creates a successful mutation result.
Declaration
public static MutationResult<TState> Success(TState newState, ChangeSet changes, IReadOnlyList<SideEffect>? sideEffects = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TState | newState | The new state after the mutation. |
| ChangeSet | changes | The set of changes applied. |
| IReadOnlyList<SideEffect> | sideEffects | Optional list of side effects. |
Returns
| Type | Description |
|---|---|
| MutationResult<TState> | A MutationResult<TState> representing success. |
Success(TState, StateChange, IReadOnlyList<SideEffect>?)
Creates a successful mutation result from a single state change.
Declaration
public static MutationResult<TState> Success(TState newState, StateChange change, IReadOnlyList<SideEffect>? sideEffects = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TState | newState | The new state after the mutation. |
| StateChange | change | The single change applied. |
| IReadOnlyList<SideEffect> | sideEffects | Optional list of side effects. |
Returns
| Type | Description |
|---|---|
| MutationResult<TState> | A MutationResult<TState> representing success. |