22
33namespace Kaitai . Async
44{
5- public interface IKaitaiAsyncStream : IKaitaiStreamBase
6- {
7- /// <summary>
8- /// Seek to a specific position from the beginning of the stream
9- /// </summary>
10- /// <param name="position">The position to seek to</param>
11- Task SeekAsync ( long position ) ;
12-
13- /// <summary>
14- /// Read a signed byte from the stream
15- /// </summary>
16- /// <returns></returns>
17- Task < sbyte > ReadS1Async ( ) ;
18-
19- /// <summary>
20- /// Read a signed short from the stream (big endian)
21- /// </summary>
22- /// <returns></returns>
23- Task < short > ReadS2beAsync ( ) ;
24-
25- /// <summary>
26- /// Read a signed int from the stream (big endian)
27- /// </summary>
28- /// <returns></returns>
29- Task < int > ReadS4beAsync ( ) ;
30-
31- /// <summary>
32- /// Read a signed long from the stream (big endian)
33- /// </summary>
34- /// <returns></returns>
35- Task < long > ReadS8beAsync ( ) ;
36-
37- /// <summary>
38- /// Read a signed short from the stream (little endian)
39- /// </summary>
40- /// <returns></returns>
41- Task < short > ReadS2leAsync ( ) ;
42-
43- /// <summary>
44- /// Read a signed int from the stream (little endian)
45- /// </summary>
46- /// <returns></returns>
47- Task < int > ReadS4leAsync ( ) ;
48-
49- /// <summary>
50- /// Read a signed long from the stream (little endian)
51- /// </summary>
52- /// <returns></returns>
53- Task < long > ReadS8leAsync ( ) ;
54-
55- /// <summary>
56- /// Read an unsigned byte from the stream
57- /// </summary>
58- /// <returns></returns>
59- Task < byte > ReadU1Async ( ) ;
60-
61- /// <summary>
62- /// Read an unsigned short from the stream (big endian)
63- /// </summary>
64- /// <returns></returns>
65- Task < ushort > ReadU2beAsync ( ) ;
66-
67- /// <summary>
68- /// Read an unsigned int from the stream (big endian)
69- /// </summary>
70- /// <returns></returns>
71- Task < uint > ReadU4beAsync ( ) ;
72-
73- /// <summary>
74- /// Read an unsigned long from the stream (big endian)
75- /// </summary>
76- /// <returns></returns>
77- Task < ulong > ReadU8beAsync ( ) ;
78-
79- /// <summary>
80- /// Read an unsigned short from the stream (little endian)
81- /// </summary>
82- /// <returns></returns>
83- Task < ushort > ReadU2leAsync ( ) ;
84-
85- /// <summary>
86- /// Read an unsigned int from the stream (little endian)
87- /// </summary>
88- /// <returns></returns>
89- Task < uint > ReadU4leAsync ( ) ;
90-
91- /// <summary>
92- /// Read an unsigned long from the stream (little endian)
93- /// </summary>
94- /// <returns></returns>
95- Task < ulong > ReadU8leAsync ( ) ;
96-
97- /// <summary>
98- /// Read a single-precision floating point value from the stream (big endian)
99- /// </summary>
100- /// <returns></returns>
101- Task < float > ReadF4beAsync ( ) ;
102-
103- /// <summary>
104- /// Read a double-precision floating point value from the stream (big endian)
105- /// </summary>
106- /// <returns></returns>
107- Task < double > ReadF8beAsync ( ) ;
108-
109- /// <summary>
110- /// Read a single-precision floating point value from the stream (little endian)
111- /// </summary>
112- /// <returns></returns>
113- Task < float > ReadF4leAsync ( ) ;
114-
115- /// <summary>
116- /// Read a double-precision floating point value from the stream (little endian)
117- /// </summary>
118- /// <returns></returns>
119- Task < double > ReadF8leAsync ( ) ;
120-
121- Task < ulong > ReadBitsIntAsync ( int n ) ;
122-
123- Task < ulong > ReadBitsIntLeAsync ( int n ) ;
124-
125- /// <summary>
126- /// Read a fixed number of bytes from the stream
127- /// </summary>
128- /// <param name="count">The number of bytes to read</param>
129- /// <returns></returns>
130- Task < byte [ ] > ReadBytesAsync ( long count ) ;
131-
132- /// <summary>
133- /// Read a fixed number of bytes from the stream
134- /// </summary>
135- /// <param name="count">The number of bytes to read</param>
136- /// <returns></returns>
137- Task < byte [ ] > ReadBytesAsync ( ulong count ) ;
138-
139- /// <summary>
140- /// Read all the remaining bytes from the stream until the end is reached
141- /// </summary>
142- /// <returns></returns>
143- Task < byte [ ] > ReadBytesFullAsync ( ) ;
144-
145- /// <summary>
146- /// Read a terminated string from the stream
147- /// </summary>
148- /// <param name="terminator">The string terminator value</param>
149- /// <param name="includeTerminator">True to include the terminator in the returned string</param>
150- /// <param name="consumeTerminator">True to consume the terminator byte before returning</param>
151- /// <param name="eosError">True to throw an error when the EOS was reached before the terminator</param>
152- /// <returns></returns>
153- Task < byte [ ] > ReadBytesTermAsync ( byte terminator , bool includeTerminator , bool consumeTerminator , bool eosError ) ;
154-
155- /// <summary>
156- /// Read a specific set of bytes and assert that they are the same as an expected result
157- /// </summary>
158- /// <param name="expected">The expected result</param>
159- /// <returns></returns>
160- Task < byte [ ] > EnsureFixedContentsAsync ( byte [ ] expected ) ;
161- }
162- }
5+ public interface IKaitaiAsyncStream : IKaitaiStreamBase
6+ {
7+ /// <summary>
8+ /// Check if the stream position is at the end of the stream
9+ /// </summary>
10+ ValueTask < bool > IsEofAsync ( ) ;
11+
12+ /// <summary>
13+ /// Get the total length of the stream (ie. file size)
14+ /// </summary>
15+ ValueTask < long > GetSizeAsync ( ) ;
16+
17+ /// <summary>
18+ /// Seek to a specific position from the beginning of the stream
19+ /// </summary>
20+ /// <param name="position">The position to seek to</param>
21+ Task SeekAsync ( long position ) ;
22+
23+ /// <summary>
24+ /// Read a signed byte from the stream
25+ /// </summary>
26+ /// <returns></returns>
27+ Task < sbyte > ReadS1Async ( ) ;
28+
29+ /// <summary>
30+ /// Read a signed short from the stream (big endian)
31+ /// </summary>
32+ /// <returns></returns>
33+ Task < short > ReadS2beAsync ( ) ;
34+
35+ /// <summary>
36+ /// Read a signed int from the stream (big endian)
37+ /// </summary>
38+ /// <returns></returns>
39+ Task < int > ReadS4beAsync ( ) ;
40+
41+ /// <summary>
42+ /// Read a signed long from the stream (big endian)
43+ /// </summary>
44+ /// <returns></returns>
45+ Task < long > ReadS8beAsync ( ) ;
46+
47+ /// <summary>
48+ /// Read a signed short from the stream (little endian)
49+ /// </summary>
50+ /// <returns></returns>
51+ Task < short > ReadS2leAsync ( ) ;
52+
53+ /// <summary>
54+ /// Read a signed int from the stream (little endian)
55+ /// </summary>
56+ /// <returns></returns>
57+ Task < int > ReadS4leAsync ( ) ;
58+
59+ /// <summary>
60+ /// Read a signed long from the stream (little endian)
61+ /// </summary>
62+ /// <returns></returns>
63+ Task < long > ReadS8leAsync ( ) ;
64+
65+ /// <summary>
66+ /// Read an unsigned byte from the stream
67+ /// </summary>
68+ /// <returns></returns>
69+ Task < byte > ReadU1Async ( ) ;
70+
71+ /// <summary>
72+ /// Read an unsigned short from the stream (big endian)
73+ /// </summary>
74+ /// <returns></returns>
75+ Task < ushort > ReadU2beAsync ( ) ;
76+
77+ /// <summary>
78+ /// Read an unsigned int from the stream (big endian)
79+ /// </summary>
80+ /// <returns></returns>
81+ Task < uint > ReadU4beAsync ( ) ;
82+
83+ /// <summary>
84+ /// Read an unsigned long from the stream (big endian)
85+ /// </summary>
86+ /// <returns></returns>
87+ Task < ulong > ReadU8beAsync ( ) ;
88+
89+ /// <summary>
90+ /// Read an unsigned short from the stream (little endian)
91+ /// </summary>
92+ /// <returns></returns>
93+ Task < ushort > ReadU2leAsync ( ) ;
94+
95+ /// <summary>
96+ /// Read an unsigned int from the stream (little endian)
97+ /// </summary>
98+ /// <returns></returns>
99+ Task < uint > ReadU4leAsync ( ) ;
100+
101+ /// <summary>
102+ /// Read an unsigned long from the stream (little endian)
103+ /// </summary>
104+ /// <returns></returns>
105+ Task < ulong > ReadU8leAsync ( ) ;
106+
107+ /// <summary>
108+ /// Read a single-precision floating point value from the stream (big endian)
109+ /// </summary>
110+ /// <returns></returns>
111+ Task < float > ReadF4beAsync ( ) ;
112+
113+ /// <summary>
114+ /// Read a double-precision floating point value from the stream (big endian)
115+ /// </summary>
116+ /// <returns></returns>
117+ Task < double > ReadF8beAsync ( ) ;
118+
119+ /// <summary>
120+ /// Read a single-precision floating point value from the stream (little endian)
121+ /// </summary>
122+ /// <returns></returns>
123+ Task < float > ReadF4leAsync ( ) ;
124+
125+ /// <summary>
126+ /// Read a double-precision floating point value from the stream (little endian)
127+ /// </summary>
128+ /// <returns></returns>
129+ Task < double > ReadF8leAsync ( ) ;
130+
131+ Task < ulong > ReadBitsIntAsync ( int n ) ;
132+
133+ Task < ulong > ReadBitsIntLeAsync ( int n ) ;
134+
135+ /// <summary>
136+ /// Read a fixed number of bytes from the stream
137+ /// </summary>
138+ /// <param name="count">The number of bytes to read</param>
139+ /// <returns></returns>
140+ Task < byte [ ] > ReadBytesAsync ( long count ) ;
141+
142+ /// <summary>
143+ /// Read a fixed number of bytes from the stream
144+ /// </summary>
145+ /// <param name="count">The number of bytes to read</param>
146+ /// <returns></returns>
147+ Task < byte [ ] > ReadBytesAsync ( ulong count ) ;
148+
149+ /// <summary>
150+ /// Read all the remaining bytes from the stream until the end is reached
151+ /// </summary>
152+ /// <returns></returns>
153+ Task < byte [ ] > ReadBytesFullAsync ( ) ;
154+
155+ /// <summary>
156+ /// Read a terminated string from the stream
157+ /// </summary>
158+ /// <param name="terminator">The string terminator value</param>
159+ /// <param name="includeTerminator">True to include the terminator in the returned string</param>
160+ /// <param name="consumeTerminator">True to consume the terminator byte before returning</param>
161+ /// <param name="eosError">True to throw an error when the EOS was reached before the terminator</param>
162+ /// <returns></returns>
163+ Task < byte [ ] > ReadBytesTermAsync ( byte terminator ,
164+ bool includeTerminator ,
165+ bool consumeTerminator ,
166+ bool eosError ) ;
167+
168+ /// <summary>
169+ /// Read a specific set of bytes and assert that they are the same as an expected result
170+ /// </summary>
171+ /// <param name="expected">The expected result</param>
172+ /// <returns></returns>
173+ Task < byte [ ] > EnsureFixedContentsAsync ( byte [ ] expected ) ;
174+ }
175+ }
0 commit comments