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 | /** Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT} */ |
| 8 | public record DeltaSuperblock( |
| 9 | Metadata metadata, |
| 10 | long timestamp, |
| 11 | Checksum fromChecksum, |
| 12 | Checksum toChecksum, |
| 13 | Commit commit, |
| 14 | List<DeltaName> dependencies, |
| 15 | List<DeltaMetaEntry> entries, |
| 16 | List<DeltaFallback> fallbacks) { |
| 17 | |
| 18 | public record DeltaName(Checksum fromChecksum, Checksum toChecksum) { |
| 19 | |
| 20 | private static final Decoder<DeltaName> DECODER = |
| 21 | Decoder.ofStructure(DeltaName.class, Checksum.decoder(), Checksum.decoder()); |
| 22 | |
| 23 | public static Decoder<DeltaName> decoder() { |
| 24 | return DECODER; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | private static final Decoder<DeltaSuperblock> DECODER = |
| 29 | Decoder.ofStructure( |
| 30 | DeltaSuperblock.class, |
| 31 | Metadata.decoder(), |
| 32 | Decoder.ofLong().withByteOrder(ByteOrder.BIG_ENDIAN), |
| 33 | Checksum.decoder(), |
| 34 | Checksum.decoder(), |
| 35 | Commit.decoder(), |
| 36 | Decoder.ofByteArray().map(x -> List.of()), // FIXME |
| 37 | Decoder.ofArray(DeltaMetaEntry.decoder()), |
| 38 | Decoder.ofArray(DeltaFallback.decoder())); |
| 39 | |
| 40 | public static Decoder<DeltaSuperblock> decoder() { |
| 41 | return DECODER; |
| 42 | } |
| 43 | } |