blob: 8f4ddf601f8df7306afdef14b5dcd9c6c2316a5f [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.nio.charset.StandardCharsets;
6import java.util.List;
7
8/**
9 * The summary file of an OSTree repository.
10 *
11 * <p>Stored as a file named {@code summary} in the OSTree repository root.
12 *
13 * <p>Reference: {@code ostree-core.h#OSTREE_SUMMARY_GVARIANT_STRING}
14 */
15public record Summary(List<Entry> entries, Metadata metadata) {
16
17 public record Entry(String ref, Value value) {
18
19 public record Value(long size, Checksum checksum, Metadata metadata) {
20
21 private static final Decoder<Value> DECODER =
22 Decoder.ofStructure(
23 Value.class,
24 Decoder.ofLong().withByteOrder(ByteOrder.LITTLE_ENDIAN),
25 Checksum.decoder(),
26 Metadata.decoder());
27
28 public static Decoder<Value> decoder() {
29 return DECODER;
30 }
31 }
32
33 private static final Decoder<Entry> DECODER =
34 Decoder.ofStructure(Entry.class, Decoder.ofString(StandardCharsets.UTF_8), Value.decoder());
35
36 public static Decoder<Entry> decoder() {
37 return DECODER;
38 }
39 }
40
41 private static final Decoder<Summary> DECODER =
42 Decoder.ofStructure(Summary.class, Decoder.ofArray(Entry.decoder()), Metadata.decoder());
43
44 public static Decoder<Summary> decoder() {
45 return DECODER;
46 }
47}