Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame^] | 1 | package eu.mulk.jgvariant.ostree; |
| 2 | |
| 3 | import eu.mulk.jgvariant.core.Decoder; |
| 4 | import java.nio.ByteOrder; |
| 5 | import java.util.List; |
| 6 | |
| 7 | /** |
| 8 | * An entry in a {@link DeltaSuperblock}. |
| 9 | * |
| 10 | * <p>Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_META_ENTRY_FORMAT} |
| 11 | */ |
| 12 | public record DeltaMetaEntry( |
| 13 | int version, Checksum checksum, long size, long usize, List<DeltaObject> objects) { |
| 14 | |
| 15 | record DeltaObject(byte objectType, Checksum checksum) { |
| 16 | |
| 17 | private static final Decoder<DeltaObject> DECODER = |
| 18 | Decoder.ofStructure(DeltaObject.class, Decoder.ofByte(), Checksum.decoder()); |
| 19 | |
| 20 | public static Decoder<DeltaObject> decoder() { |
| 21 | return DECODER; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | private static final Decoder<DeltaMetaEntry> DECODER = |
| 26 | Decoder.ofStructure( |
| 27 | DeltaMetaEntry.class, |
| 28 | Decoder.ofInt().withByteOrder(ByteOrder.LITTLE_ENDIAN), // FIXME: non-canonical |
| 29 | Checksum.decoder(), |
| 30 | Decoder.ofLong().withByteOrder(ByteOrder.LITTLE_ENDIAN), // FIXME: non-canonical |
| 31 | Decoder.ofLong().withByteOrder(ByteOrder.LITTLE_ENDIAN), // FIXME: non-canonical |
| 32 | Decoder.ofByteArray().map(x -> List.of()) // FIXME |
| 33 | ); |
| 34 | |
| 35 | public static Decoder<DeltaMetaEntry> decoder() { |
| 36 | return DECODER; |
| 37 | } |
| 38 | } |