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 | |
| 6 | /** |
| 7 | * A fallback entry in a {@link DeltaSuperblock}. |
| 8 | * |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 9 | * <p>References a file in the OSTree repository. |
| 10 | * |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 11 | * <p>Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_FALLBACK_FORMAT} |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 12 | * |
| 13 | * @param objectType the object type of the file represented by this fallback entry. |
| 14 | * @param checksum the checksum of the file represented by this fallback entry. |
| 15 | * @param compressedSize the compressed size of the file represented by this fallback entry. |
| 16 | * @param uncompressedSize the uncompressed size of the file represented by this fallback entry. |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 17 | */ |
| 18 | public record DeltaFallback( |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 19 | ObjectType objectType, Checksum checksum, long compressedSize, long uncompressedSize) { |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 20 | |
| 21 | private static final Decoder<DeltaFallback> DECODER = |
| 22 | Decoder.ofStructure( |
| 23 | DeltaFallback.class, |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 24 | Decoder.ofByte().map(ObjectType::valueOf), |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 25 | Checksum.decoder(), |
| 26 | Decoder.ofLong().withByteOrder(ByteOrder.LITTLE_ENDIAN), // FIXME: non-canonical |
| 27 | Decoder.ofLong().withByteOrder(ByteOrder.LITTLE_ENDIAN)); // FIXME: non-canonical |
| 28 | |
Matthias Andreas Benkard | 0511464 | 2021-12-29 21:51:29 +0100 | [diff] [blame] | 29 | /** |
| 30 | * Acquires a {@link Decoder} for the enclosing type. |
| 31 | * |
| 32 | * @return a possibly shared {@link Decoder}. |
| 33 | */ |
Matthias Andreas Benkard | 4e8423d | 2021-12-19 22:56:09 +0100 | [diff] [blame] | 34 | public static Decoder<DeltaFallback> decoder() { |
| 35 | return DECODER; |
| 36 | } |
| 37 | } |