VirtualFileSystem

Atypical.VirtualFileSystem.Core

Atypical.VirtualFileSystem.Core

Result<T> Struct

Represents the result of an operation that can either succeed or fail without throwing exceptions.

public readonly record struct Result<T> : System.IEquatable<Atypical.VirtualFileSystem.Core.Result<T>>

Type parameters

T

The type of the success value.

Implements System.IEquatable<Atypical.VirtualFileSystem.Core.Result<T>>

Properties  
Error Gets the error message. Only available when IsFailure is true.
IsFailure Gets a value indicating whether the operation failed.
IsSuccess Gets a value indicating whether the operation was successful.
Value Gets the success value. Only available when IsSuccess is true.
Methods  
Bind<TNew>(Func<T,Result<TNew>>) Transforms the success value to another result.
Deconstruct(bool, object) Deconstructs the result into success flag and value/error.
Failure(string) Creates a failed result with the specified error message.
Failure(Exception) Creates a failed result from an exception.
GetValueOrDefault(Func<string,T>) Gets the value if successful, or gets a value from the specified function.
GetValueOrDefault(T) Gets the value if successful, or returns the specified default value.
Map<TNew>(Func<T,TNew>) Transforms the success value to another type.
OnFailure(Action<string>) Executes an action if the result is a failure.
OnSuccess(Action<T>) Executes an action if the result is successful.
Success(T) Creates a successful result with the specified value.
ToString() Returns a string representation of the result.
Operators  
implicit operator Result<T>(T) Implicitly converts a value to a successful result.