|
| 1 | +using System.Threading.Tasks; |
| 2 | + |
| 3 | +namespace Kaitai.Async |
| 4 | +{ |
| 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 | + Task<ulong> ReadBitsIntLeAsync(int n); |
| 123 | + |
| 124 | + /// <summary> |
| 125 | + /// Read a fixed number of bytes from the stream |
| 126 | + /// </summary> |
| 127 | + /// <param name="count">The number of bytes to read</param> |
| 128 | + /// <returns></returns> |
| 129 | + Task<byte[]> ReadBytesAsync(long count); |
| 130 | + |
| 131 | + /// <summary> |
| 132 | + /// Read a fixed number of bytes from the stream |
| 133 | + /// </summary> |
| 134 | + /// <param name="count">The number of bytes to read</param> |
| 135 | + /// <returns></returns> |
| 136 | + Task<byte[]> ReadBytesAsync(ulong count); |
| 137 | + |
| 138 | + /// <summary> |
| 139 | + /// Read all the remaining bytes from the stream until the end is reached |
| 140 | + /// </summary> |
| 141 | + /// <returns></returns> |
| 142 | + Task<byte[]> ReadBytesFullAsync(); |
| 143 | + |
| 144 | + /// <summary> |
| 145 | + /// Read a terminated string from the stream |
| 146 | + /// </summary> |
| 147 | + /// <param name="terminator">The string terminator value</param> |
| 148 | + /// <param name="includeTerminator">True to include the terminator in the returned string</param> |
| 149 | + /// <param name="consumeTerminator">True to consume the terminator byte before returning</param> |
| 150 | + /// <param name="eosError">True to throw an error when the EOS was reached before the terminator</param> |
| 151 | + /// <returns></returns> |
| 152 | + Task<byte[]> ReadBytesTermAsync(byte terminator, bool includeTerminator, bool consumeTerminator, bool eosError); |
| 153 | + |
| 154 | + /// <summary> |
| 155 | + /// Read a specific set of bytes and assert that they are the same as an expected result |
| 156 | + /// </summary> |
| 157 | + /// <param name="expected">The expected result</param> |
| 158 | + /// <returns></returns> |
| 159 | + Task<byte[]> EnsureFixedContentsAsync(byte[] expected); |
| 160 | + } |
| 161 | +} |
0 commit comments