public static Task <Either <InfusioError, InfusioResult <T> > > RunWithLogs <T>(this InfusioOp <T> op, InfusioClient client, IEnumerable <string> logs = default) => RunAsync(op, InfusioState.Create(Seq(logs), useLogging: true), client).ToEither();
static EitherAsync <InfusioError, InfusioResult <T> > RunAsync <T>(InfusioOp <T> op, InfusioState state, InfusioClient client) => op is InfusioOp <T> .Return r?Right <InfusioError, InfusioResult <T> >(new InfusioResult <T>(r.Value, state.Logs)).ToAsync() :
public static Task <Either <InfusioError, InfusioResult <T> > > Run <T>(this InfusioOp <T> op, InfusioClient client, InfusioState state) => RunAsync(op, state, client).ToEither();
public static Task <Either <InfusioError, T> > Run <T>(this InfusioOp <T> op, InfusioClient client) => RunAsync(op, InfusioState.Create(useLogging: false), client).Match( Left: e => Left <InfusioError, T>(e), Right: r => r.Value );
static InfusioState LogResult <T>(InfusioState state, T value) => typeof(T) == typeof(Unit) ? state : state.UseLogging ? state.Log($"OK: {SerializeObject(value, Indented)}") : state;
static InfusioState LogRequest <T>(InfusioState state, Show <InfusioOp <T> > show) => state.UseLogging ? state.Log(show()) : state;
static EitherAsync <InfusioError, InfusioResult <B> > Exe <T, B>(Show <InfusioOp <T> > show, HttpWorkflow <T> workflow, Func <T, InfusioOp <B> > nextOp, InfusioState state, InfusioClient client) => from right in LogOperation(show, workflow, state, client).ToAsync() from next in RunAsync(nextOp(right.Value), right.State, client) select next;