feat: add inital in memory dispatcher
Some checks failed
default / dotnet-default-workflow (push) Failing after 1m24s
Some checks failed
default / dotnet-default-workflow (push) Failing after 1m24s
Add a simple in memory dispatcher for scalar requests and stream request.
This commit is contained in:
commit
ce50fcd1a3
145 changed files with 6384 additions and 0 deletions
51
src/request.result/Result.Conversion.cs
Normal file
51
src/request.result/Result.Conversion.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (c) The Geekeey Authors
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
using System.Diagnostics.Contracts;
|
||||
|
||||
namespace Geekeey.Request.Result;
|
||||
|
||||
public readonly partial struct Result<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Implicitly constructs a result from a success value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to construct the result from.</param>
|
||||
[Pure]
|
||||
public static implicit operator Result<T>(T value)
|
||||
{
|
||||
return new Result<T>(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implicitly constructs a result from a failure value.
|
||||
/// </summary>
|
||||
/// <param name="error">The error to construct the result from.</param>
|
||||
[Pure]
|
||||
public static implicit operator Result<T>(Error error)
|
||||
{
|
||||
return new Result<T>(error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unwraps the success value of the result. Throws an <see cref="UnwrapException"/> if the result is a failure.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This call is <b>unsafe</b> in the sense that it might intentionally throw an exception. Please only use this
|
||||
/// call if the caller knows that this operation is safe, or that an exception is acceptable to be thrown.
|
||||
/// </remarks>
|
||||
/// <returns>The success value of the result.</returns>
|
||||
/// <exception cref="UnwrapException">The result is not a success.</exception>
|
||||
[Pure]
|
||||
public T Unwrap()
|
||||
{
|
||||
return IsSuccess ? Value : throw new UnwrapException();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="Unwrap"/>
|
||||
[Pure]
|
||||
public static explicit operator T(Result<T> result)
|
||||
{
|
||||
return result.Unwrap();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue