master
h 49 lines 1.52 KB
Raw
1 /*++
2
3 Copyright (c) Microsoft. All rights reserved.
4
5 Module Name:
6
7 Streams.h
8
9 Abstract:
10
11 This file contains the definition of WinRT stream wrappers for IO handles.
12 --*/
13
14 #pragma once
15 #include <winrt/Windows.Storage.Streams.h>
16
17 namespace winrt::Microsoft::WSL::Containers::implementation {
18
19 // WinRT IInputStream wrapper around a Windows HANDLE (read end).
20 struct IOHandleInputStream
21 : winrt::implements<IOHandleInputStream, winrt::Windows::Storage::Streams::IInputStream, winrt::Windows::Foundation::IClosable>
22 {
23 explicit IOHandleInputStream(wil::unique_handle&& handle);
24
25 winrt::Windows::Foundation::IAsyncOperationWithProgress<winrt::Windows::Storage::Streams::IBuffer, uint32_t> ReadAsync(
26 winrt::Windows::Storage::Streams::IBuffer buffer, uint32_t count, winrt::Windows::Storage::Streams::InputStreamOptions options);
27
28 void Close();
29
30 private:
31 wil::unique_handle m_handle;
32 };
33
34 // WinRT IOutputStream wrapper around a Windows HANDLE (write end).
35 struct IOHandleOutputStream
36 : winrt::implements<IOHandleOutputStream, winrt::Windows::Storage::Streams::IOutputStream, winrt::Windows::Foundation::IClosable>
37 {
38 explicit IOHandleOutputStream(wil::unique_handle&& handle);
39
40 winrt::Windows::Foundation::IAsyncOperationWithProgress<uint32_t, uint32_t> WriteAsync(winrt::Windows::Storage::Streams::IBuffer const& buffer);
41 winrt::Windows::Foundation::IAsyncOperation<bool> FlushAsync();
42
43 void Close();
44
45 private:
46 wil::unique_handle m_handle;
47 };
48
49 } // namespace winrt::Microsoft::WSL::Containers::implementation