Struct MutationResult<TState>
Represents the outcome of mutation operation for a given state type.
Implements
Inherited Members
Namespace: ModularityKit.Mutator.Abstractions.Results
Assembly: ModularityKit.Mutator.dll
Syntax
public readonly record struct MutationResult<TState> : IEquatable<MutationResult<TState>>
Type Parameters
| Name | Description |
|---|---|
| TState | The type of the state object being mutated. |
Constructors
| Edit this page View SourceMutationResult()
Declaration
public MutationResult()
Properties
| Edit this page View SourceChanges
The set of changes applied by the mutation.
Declaration
public ChangeSet Changes { get; init; }
Property Value
| Type | Description |
|---|---|
| ChangeSet |
CompletedAt
Timestamp when the mutation completed.
Declaration
public DateTimeOffset CompletedAt { get; init; }
Property Value
| Type | Description |
|---|---|
| DateTimeOffset |
Exception
Exception thrown during the mutation, if any.
Declaration
public Exception? Exception { get; init; }
Property Value
| Type | Description |
|---|---|
| Exception |
IsSuccess
Indicates whether the mutation completed successfully.
Declaration
public bool IsSuccess { get; init; }
Property Value
| Type | Description |
|---|---|
| bool |
Metrics
Metrics collected during the mutation execution.
Declaration
public MutationMetrics Metrics { get; init; }
Property Value
| Type | Description |
|---|---|
| MutationMetrics |
NewState
The new state after a successful mutation, or default if unsuccessful.
Declaration
public TState? NewState { get; init; }
Property Value
| Type | Description |
|---|---|
| TState |
PolicyDecisions
Policy decisions that were made during mutation evaluation.
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
Validation result indicating any validation errors or warnings.
Declaration
public ValidationResult ValidationResult { get; init; }
Property Value
| Type | Description |
|---|---|
| ValidationResult |
Methods
| Edit this page View SourceFailure(ValidationResult)
Creates failed mutation result with validation errors.
Declaration
public static MutationResult<TState> Failure(ValidationResult validation)
Parameters
| Type | Name | Description |
|---|---|---|
| ValidationResult | validation | The validation result describing the failure. |
Returns
| Type | Description |
|---|---|
| MutationResult<TState> | A failed MutationResult<TState>. |
PolicyBlocked(PolicyDecision)
Creates mutation result blocked by policy decision.
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 blocked MutationResult<TState>. |
Success(TState, ChangeSet, IReadOnlyList<SideEffect>?)
Creates successful mutation result with the given state and changes.
Declaration
public static MutationResult<TState> Success(TState newState, ChangeSet changes, IReadOnlyList<SideEffect>? sideEffects = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TState | newState | The new state after mutation. |
| ChangeSet | changes | The set of changes applied. |
| IReadOnlyList<SideEffect> | sideEffects | Optional list of side effects. |
Returns
| Type | Description |
|---|---|
| MutationResult<TState> | A successful MutationResult<TState>. |
Success(TState, StateChange, IReadOnlyList<SideEffect>?)
Creates successful mutation result with 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 mutation. |
| StateChange | change | The single state change applied. |
| IReadOnlyList<SideEffect> | sideEffects | Optional list of side effects. |
Returns
| Type | Description |
|---|---|
| MutationResult<TState> | A successful MutationResult<TState>. |