public static AwaitableWrapper WriteAsyncR(this IMyStream myStream, BytesSegment bs) { if (myStream is IMyStreamWriteR myStreamReuse) { return(myStreamReuse.WriteAsyncR(bs)); } return(new AwaitableWrapper(myStream.WriteAsync(bs))); }
public static void Write(this IMyStream myStream, byte[] buf, int offset, int count) { if (myStream is IMyStreamSync sync) { sync.Write(new BytesSegment(buf, offset, count)); } else { myStream.WriteAsync(buf, offset, count).RunSync(); } }
public static AwaitableWrapper WriteMultipleAsyncR(this IMyStream myStream, BytesView bv) { if (myStream is IMyStreamMultiBuffer bvs) { return(bvs.WriteMultipleAsyncR(bv)); } else { return(new AwaitableWrapper(NaiveUtils.RunAsyncTask(async() => { foreach (var item in bv) { if (item.len > 0) { await myStream.WriteAsync(new BytesSegment(item)); } } }))); } }
public static Task WriteAsync(this IMyStream myStream, byte[] buf, int offset, int count) { return(myStream.WriteAsync(new BytesSegment(buf, offset, count))); }