internal static ValueTask DoUnaryOperation(ref int value, UnaryOperationCommand command, CancellationToken token) { value = command.Type switch { UnaryOperation.Negate => - command.X, UnaryOperation.OnesComplement => ~command.X, _ => throw new NotSupportedException() }; return(new ValueTask()); }
unsafe long?IFormatter <UnaryOperationCommand> .GetLength(UnaryOperationCommand command) => sizeof(UnaryOperationCommand);
async ValueTask IFormatter <UnaryOperationCommand> .SerializeAsync <TWriter>(UnaryOperationCommand command, TWriter writer, CancellationToken token) { await writer.WriteInt32Async(command.X, true, token); await writer.WriteAsync(command.Type, token); }
public ValueTask DoUnaryOperation(UnaryOperationCommand command, CancellationToken token) => DoUnaryOperation(ref Value, command, token);