Beispiel #1
0
        public static RdTaskResult <T> Read(CtxReadDelegate <T> readDelegate, SerializationCtx ctx, UnsafeReader reader)
        {
            var status = (RdTaskStatus)reader.ReadInt();

            switch (status)
            {
            case RdTaskStatus.Success: return(Success(readDelegate(ctx, reader)));

            case RdTaskStatus.Canceled: return(Cancelled());

            case RdTaskStatus.Faulted: return(Faulted(RdFault.Read(ctx, reader)));

            default:
                throw new ArgumentOutOfRangeException($"Unknown status of {nameof(RdTaskStatus)}: {status}");
            }
        }
Beispiel #2
0
        public static void Write(CtxWriteDelegate <T> writeDelegate, SerializationCtx ctx, UnsafeWriter writer, RdTaskResult <T> value)
        {
            writer.Write((int)value.Status);

            switch (value.Status)
            {
            case RdTaskStatus.Success:
                writeDelegate(ctx, writer, value.Result);
                break;

            case RdTaskStatus.Canceled:
                break;

            case RdTaskStatus.Faulted:
                RdFault.Write(ctx, writer, value.Error);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #3
0
 public static void Write(SerializationCtx ctx, UnsafeWriter writer, RdFault value)
 {
     writer.Write(value.ReasonTypeFqn);
     writer.Write(value.ReasonMessage);
     writer.Write(value.ReasonText);
 }
Beispiel #4
0
 private RdTaskResult(RdTaskStatus status, T result, RdFault error)
 {
     Status = status;
     Result = result;
     Error  = error;
 }
Beispiel #5
0
 internal RdTaskResult(RdTaskStatus status, T result, RdFault error)
 {
     myStatus = status;
     myResult = result;
     myError  = error;
 }