public ValueTask SerializePipe() { var pipe = PipeWriter.Create(Stream.Null); CborWriter cborWriter = new CborWriter(pipe); var t = ComplexClassFormatter <Document> .Default.SerializeAsync(cborWriter, document); if (t.IsCompletedSuccessfully) { return(cborWriter.CompleteAsync()); } return(AwaitComplete(t, cborWriter)); }
private async ValueTask AwaitComplete(ValueTask valueTask, CborWriter writer) { await valueTask.ConfigureAwait(false); await writer.CompleteAsync(); }