blob: 57c8fc527c2caaa8223b9b53cd4197c89ff38ba0 [file] [log] [blame]
Matthias Andreas Benkardb5d657a2022-02-03 21:14:30 +01001// SPDX-FileCopyrightText: © 2021 Matthias Andreas Benkard <code@mail.matthias.benkard.de>
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +01005package eu.mulk.jgvariant.ostree;
6
7import eu.mulk.jgvariant.core.Decoder;
8import java.nio.ByteOrder;
9
10/**
11 * A fallback entry in a {@link DeltaSuperblock}.
12 *
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010013 * <p>References a file in the OSTree repository.
14 *
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010015 * <p>Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_FALLBACK_FORMAT}
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010016 *
17 * @param objectType the object type of the file represented by this fallback entry.
18 * @param checksum the checksum of the file represented by this fallback entry.
19 * @param compressedSize the compressed size of the file represented by this fallback entry.
20 * @param uncompressedSize the uncompressed size of the file represented by this fallback entry.
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010021 */
22public record DeltaFallback(
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010023 ObjectType objectType, Checksum checksum, long compressedSize, long uncompressedSize) {
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010024
25 private static final Decoder<DeltaFallback> DECODER =
26 Decoder.ofStructure(
27 DeltaFallback.class,
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010028 Decoder.ofByte().map(ObjectType::valueOf),
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010029 Checksum.decoder(),
Matthias Andreas Benkarda8514a32021-12-30 21:01:48 +010030 Decoder.ofLong(),
31 Decoder.ofLong());
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010032
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010033 /**
34 * Acquires a {@link Decoder} for the enclosing type.
35 *
Matthias Andreas Benkarda8514a32021-12-30 21:01:48 +010036 * <p><strong>Note:</strong> This decoder has an unspecified {@link ByteOrder}.
37 *
Matthias Andreas Benkard05114642021-12-29 21:51:29 +010038 * @return a possibly shared {@link Decoder}.
39 */
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010040 public static Decoder<DeltaFallback> decoder() {
41 return DECODER;
42 }
Matthias Andreas Benkarda8514a32021-12-30 21:01:48 +010043
44 DeltaFallback byteSwapped() {
45 return new DeltaFallback(objectType, checksum, compressedSize, uncompressedSize);
46 }
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010047}