(ByteBuf bytes)
| 34 | } |
| 35 | |
| 36 | public static WrittenType readType(ByteBuf bytes) throws IOException { |
| 37 | byte val = bytes.readByte(); |
| 38 | for (WrittenType type : ORDERED_VALUES) { |
| 39 | if (val == type.numBytes - 1) { |
| 40 | return type; |
| 41 | } |
| 42 | } |
| 43 | throw new IOException("Incorrect size given, expected any of [0, 1, 2, 3] but got " + val); |
| 44 | } |
| 45 | |
| 46 | public void writeIndex(ByteBuf bytes, int index) { |
| 47 | switch (this) { |