blob: 0967043fdf7549a949b056f71c6ec8bd473aa840 [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;
5
6/**
7 * A fallback entry in a {@link DeltaSuperblock}.
8 *
Matthias Andreas Benkard05114642021-12-29 21:51:29 +01009 * <p>References a file in the OSTree repository.
10 *
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010011 * <p>Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_FALLBACK_FORMAT}
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010012 *
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 Benkard4e8423d2021-12-19 22:56:09 +010017 */
18public record DeltaFallback(
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010019 ObjectType objectType, Checksum checksum, long compressedSize, long uncompressedSize) {
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010020
21 private static final Decoder<DeltaFallback> DECODER =
22 Decoder.ofStructure(
23 DeltaFallback.class,
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010024 Decoder.ofByte().map(ObjectType::valueOf),
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010025 Checksum.decoder(),
Matthias Andreas Benkarda8514a32021-12-30 21:01:48 +010026 Decoder.ofLong(),
27 Decoder.ofLong());
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010028
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010029 /**
30 * Acquires a {@link Decoder} for the enclosing type.
31 *
Matthias Andreas Benkarda8514a32021-12-30 21:01:48 +010032 * <p><strong>Note:</strong> This decoder has an unspecified {@link ByteOrder}.
33 *
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010034 * @return a possibly shared {@link Decoder}.
35 */
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010036 public static Decoder<DeltaFallback> decoder() {
37 return DECODER;
38 }
Matthias Andreas Benkarda8514a32021-12-30 21:01:48 +010039
40 DeltaFallback byteSwapped() {
41 return new DeltaFallback(objectType, checksum, compressedSize, uncompressedSize);
42 }
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010043}