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.nio.charset.StandardCharsets; |
| 6 | import 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 | */ |
| 15 | public 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 | } |