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 | /** |
| 8 | * Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_PART_PAYLOAD_FORMAT_V0} |
| 9 | */ |
| 10 | public 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 | } |