Struct Result<TValue>
Namespace: OceanApocalypse.RSML.Toolchain.Abstractions.Diagnostics
Assembly: RSML.Toolchain.Abstractions.dll
An operation's result.
public readonly struct Result<TValue> : IEquatable<Result<TValue>>
Type Parameters
TValue
The type of the return value when successful.
Implements
Inherited Members
Object.Equals(Object?), Object.Equals(Object?, Object?), Object.GetHashCode(), Object.GetType(), Object.ReferenceEquals(Object?, Object?), Object.ToString()
Properties
Error
The diagnostic that serves as the error value when an error occurs.
Might be null or an arbitrary default if IsError is true.
public Diagnostic Error { get; }
Property Value
IsError
Set to false when the operation is successful. Otherwise, it's set to true.
It also indicates whether Value can be safely accessed or not (safe to access if
IsError is false).
public Boolean IsError { get; }
Property Value
Remarks
IsSuccessful and IsError are mutually exclusive conditions. When one is true,
the other is false. This means you can use any of the two to evaluate whether the operation was successful
and if it's safe to access Value.
IsSuccessful
Set to true when the operation is successful. Otherwise, it's set to false.
It also indicates whether Value can be safely accessed or not (safe to access if
IsSuccessful is true).
[MemberNotNullWhen(true, "Value")]
public Boolean IsSuccessful { get; }
Property Value
Remarks
IsSuccessful and IsError are mutually exclusive conditions. When one is true,
the other is false. This means you can use any of the two to evaluate whether the operation was successful
and if it's safe to access Value.
Value
The return value. Might be null or an arbitrary default if
IsSuccessful is false.
[MemberNotNullWhen(true, "Value")]
public TValue? Value { get; }
Property Value
TValue?
Methods
Equals(Object?)
Checks if a given object is equal to the current instance.
public override Boolean Equals(Object? obj)
Parameters
obj Object?
The object to check against.
Returns
True if equals
Equals(Result<TValue>)
Checks if a given result is equal to the current instance.
public Boolean Equals(Result<TValue> other)
Parameters
other Result<TValue>
The result to check against.
Returns
True if equals
GetHashCode()
Returns the hash code for this instance.
public override Int32 GetHashCode()
Returns
A 32-bit signed integer that is the hash code for this instance.
Operators
operator ==(Result<TValue>, Result<TValue>)
Checks if two results are equals.
public static Boolean operator ==(Result<TValue> left, Result<TValue> right)
Parameters
left Result<TValue>
right Result<TValue>
Returns
True if equals
operator !=(Result<TValue>, Result<TValue>)
Checks if two results are different.
public static Boolean operator !=(Result<TValue> left, Result<TValue> right)
Parameters
left Result<TValue>
right Result<TValue>
Returns
True if different