blob: c8c5fe7603d5f0f203ca12620022d4976dd5d5d2 [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 * Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_PART_PAYLOAD_FORMAT_V0}
9 */
10public record DeltaPartPayload(
11 List<FileMode> fileModes,
12 List<List<Xattr>> xattrs,
13 ByteString rawDataSource,
14 ByteString operations) {
15
16 private static final Decoder<DeltaPartPayload> DECODER =
17 Decoder.ofStructure(
18 DeltaPartPayload.class,
19 Decoder.ofArray(FileMode.decoder()),
20 Decoder.ofArray(Decoder.ofArray(Xattr.decoder())),
21 ByteString.decoder(),
22 ByteString.decoder());
23
24 public record FileMode(int uid, int gid, int mode) {
25
26 private static final Decoder<FileMode> DECODER =
27 Decoder.ofStructure(
28 FileMode.class,
29 Decoder.ofInt().withByteOrder(ByteOrder.LITTLE_ENDIAN),
30 Decoder.ofInt().withByteOrder(ByteOrder.LITTLE_ENDIAN),
31 Decoder.ofInt().withByteOrder(ByteOrder.LITTLE_ENDIAN));
32
33 public static Decoder<FileMode> decoder() {
34 return DECODER;
35 }
36 }
37
38 public static Decoder<DeltaPartPayload> decoder() {
39 return DECODER;
40 }
41}