blob: 303e344c38585197006a1e5ee07ad39661e8d48b [file] [log] [blame]
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +01001package eu.mulk.jgvariant.ostree;
2
3import eu.mulk.jgvariant.core.Decoder;
4import eu.mulk.jgvariant.core.Variant;
5import java.nio.ByteOrder;
6import java.nio.charset.StandardCharsets;
Matthias Andreas Benkard329168c2021-12-28 01:20:05 +01007import java.util.Map;
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +01008
9/**
10 * A {@link DeltaSuperblock} signed with some sort of key.
11 *
12 * <p>Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_SIGNED_FORMAT}
13 */
14public record SignedDelta(
Matthias Andreas Benkard329168c2021-12-28 01:20:05 +010015 long magicNumber, ByteString superblock, Map<String, Variant> signatures) {
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010016
17 private static final Decoder<SignedDelta> DECODER =
18 Decoder.ofStructure(
19 SignedDelta.class,
20 Decoder.ofLong().withByteOrder(ByteOrder.BIG_ENDIAN),
21 ByteString.decoder(),
Matthias Andreas Benkard329168c2021-12-28 01:20:05 +010022 Decoder.ofDictionary(Decoder.ofString(StandardCharsets.US_ASCII), Decoder.ofVariant()));
Matthias Andreas Benkard4e8423d2021-12-19 22:56:09 +010023
24 public static Decoder<SignedDelta> decoder() {
25 return DECODER;
26 }
27}