Logo ProcessKit API Reference

ResultExtensions Type

 C#-idiomatic consumption of the `Result<'T, ProcessError>` that every verb returns. F# matches
 `Ok`/`Error` directly; C# pattern-matches the result with no projection or helper call, using the
 result's own members:

 
 await cmd.OutputStringAsync() switch
 {
     { IsOk: true,  ResultValue: var run } => run.Stdout,
     { IsOk: false, ErrorValue: var err } => err.Message,
 }
 

 The match is exhaustive (the `IsOk` bool covers both arms — no discard needed); `ResultValue` is
 read only in the `IsOk: true` arm (the pattern short-circuits) and binds non-null, so no `!`. For
 non-`switch` styles these extensions give `Match` / `Switch`, `TryGetValue`, and `GetValueOrThrow`
 without touching the result's members. A `Result` is never `null`, and the Try out-parameters
 follow the standard .NET pattern.

Static members

Static member Description

ResultExtensions.GetValueOrThrow(result)

Full Usage: ResultExtensions.GetValueOrThrow(result)

Parameters:
Returns: 'T
Type parameters: 'T

The success value, or raise `ProcessException` carrying the error.

result : Result<'T, ProcessError>
Returns: 'T

ResultExtensions.Match(result, onOk, onError)

Full Usage: ResultExtensions.Match(result, onOk, onError)

Parameters:
Returns: 'R
Type parameters: 'T, 'R

Project both cases to a single value.

result : Result<'T, ProcessError>
onOk : Func<'T, 'R>
onError : Func<ProcessError, 'R>
Returns: 'R

ResultExtensions.Switch(result, onOk, onError)

Full Usage: ResultExtensions.Switch(result, onOk, onError)

Parameters:
Type parameters: 'T

Run the matching side effect (no return value).

result : Result<'T, ProcessError>
onOk : Action<'T>
onError : Action<ProcessError>

ResultExtensions.TryGetValue(result, value, error)

Full Usage: ResultExtensions.TryGetValue(result, value, error)

Parameters:
Returns: bool
Type parameters: 'T

On success returns `true` and sets `value`; on failure returns `false` and sets `error`. The nullability attributes make the standard Try-pattern honest to nullable-aware C#: read `value` only when the call returned `true`, and `error` only when it returned `false`.

result : Result<'T, ProcessError>
value : byref<'T>
error : byref<ProcessError>
Returns: bool

Type something to start searching.