Fauna csharp driver  4.2.0
Public Member Functions | Properties | List of all members
FaunaDB.Types.IResult< T > Interface Template Reference

Represents the result of an operation. Usually a coercion operation. More...

Inherited by FaunaDB.Types.Failure< T >, and FaunaDB.Types.Success< T >.

Public Member Functions

IResult< U > Map< U > (Func< T, U > func)
 Apply the function passed on the result value. More...
 
IResult< U > FlatMap< U > (Func< T, IResult< U >> func)
 Apply the function passed on the result value. More...
 
Match< U > (Func< T, U > Success, Func< string, U > Failure)
 Matches the current instance. Case it represents a successful result it will execute the first argument. Case it represents a failure object it will execute the second argument. More...
 
void Match (Action< T > Success, Action< string > Failure)
 Matches the current instance. Case it represents a successful result it will execute the first argument. Case it represents a failure object it will execute the second argument. More...
 

Properties

Value [get]
 Extracts the resulting value or throw an exception if the operation has failed. More...
 
IOption< T > ToOption [get]
 Gets an IOption<T> type containing the result value if the operation was successful, or Option.None<T>() if it was a failure More...
 
bool isSuccess [get]
 Return true if the operation was successful More...
 
bool isFailure [get]
 Return true if the operation has failed More...
 

Detailed Description

Represents the result of an operation. Usually a coercion operation.

Definition at line 8 of file Result.cs.

Member Function Documentation

◆ FlatMap< U >()

IResult<U> FaunaDB.Types.IResult< T >.FlatMap< U > ( Func< T, IResult< U >>  func)

Apply the function passed on the result value.

Parameters
functhe map function to be applied
Returns
If this is a successful result, returns the map function result. If this is a failure, returns a new failure with the same error message.

◆ Map< U >()

IResult<U> FaunaDB.Types.IResult< T >.Map< U > ( Func< T, U >  func)

Apply the function passed on the result value.

Parameters
functhe map function to be applied
Returns
If this is a successful result, return a new successful result with the map function result. If this is a failure, returns a new failure with the same error message.

◆ Match()

void FaunaDB.Types.IResult< T >.Match ( Action< T >  Success,
Action< string >  Failure 
)

Matches the current instance. Case it represents a successful result it will execute the first argument. Case it represents a failure object it will execute the second argument.

IResult<string> result = ...

result.Match( Success: value => DoSomething(), Failure: reason => DoSomethingElse(reason) );

Parameters
SuccessAction to be executed case this instance represents a successful result
FailureAction to be executed case this instance represents a failure result

◆ Match< U >()

U FaunaDB.Types.IResult< T >.Match< U > ( Func< T, U >  Success,
Func< string, U >  Failure 
)

Matches the current instance. Case it represents a successful result it will execute the first argument. Case it represents a failure object it will execute the second argument.

IResult<string> result = ... int parsed = result.Match( Success: value => int.Parse(value), Failure: reason => ReturnDefaultValue() );

Parameters
SuccessFunction to be executed case this instance represents a successful result
FailureFunction to be executed case this instance represents a failure result

Property Documentation

◆ isFailure

bool FaunaDB.Types.IResult< T >.isFailure
get

Return true if the operation has failed

Definition at line 81 of file Result.cs.

◆ isSuccess

bool FaunaDB.Types.IResult< T >.isSuccess
get

Return true if the operation was successful

Definition at line 76 of file Result.cs.

◆ ToOption

IOption<T> FaunaDB.Types.IResult< T >.ToOption
get

Gets an IOption<T> type containing the result value if the operation was successful, or Option.None<T>() if it was a failure

Definition at line 71 of file Result.cs.

◆ Value

Extracts the resulting value or throw an exception if the operation has failed.

Exceptions
InvalidOperationException

Definition at line 65 of file Result.cs.


The documentation for this interface was generated from the following file: