blob: 39ada86d2efb80df6e6f83993c5e8345b3d37a16 [file] [log] [blame]
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +01001package eu.mulk.jgvariant.ostree;
2
3import eu.mulk.jgvariant.core.Decoder;
4import java.nio.ByteOrder;
5import 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 */
12public 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}