diff options
Diffstat (limited to 'jgvariant-ostree/src/main')
3 files changed, 11 insertions, 44 deletions
diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Metadata.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Metadata.java index cf838d3..8bb5255 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Metadata.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Metadata.java @@ -3,29 +3,18 @@ package eu.mulk.jgvariant.ostree; import eu.mulk.jgvariant.core.Decoder; import eu.mulk.jgvariant.core.Variant; import java.nio.charset.StandardCharsets; -import java.util.List; +import java.util.Map; /** * A wrapper for a list of metadata fields. * * <p>Reference: (embedded in other data types) */ -public record Metadata(List<Field> fields) { - - /** A metadata field with a key and a value. */ - public record Field(String key, Variant value) { - - private static final Decoder<Field> DECODER = - Decoder.ofStructure( - Field.class, Decoder.ofString(StandardCharsets.UTF_8), Decoder.ofVariant()); - - public static Decoder<Field> decoder() { - return DECODER; - } - } +public record Metadata(Map<String, Variant> fields) { private static final Decoder<Metadata> DECODER = - Decoder.ofArray(Field.decoder()).map(Metadata::new); + Decoder.ofDictionary(Decoder.ofString(StandardCharsets.UTF_8), Decoder.ofVariant()) + .map(Metadata::new); public static Decoder<Metadata> decoder() { return DECODER; diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SignedDelta.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SignedDelta.java index 2fc5c25..303e344 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SignedDelta.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SignedDelta.java @@ -4,7 +4,7 @@ import eu.mulk.jgvariant.core.Decoder; import eu.mulk.jgvariant.core.Variant; import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; -import java.util.List; +import java.util.Map; /** * A {@link DeltaSuperblock} signed with some sort of key. @@ -12,25 +12,14 @@ import java.util.List; * <p>Reference: {@code ostree-repo-static-delta-private.h#OSTREE_STATIC_DELTA_SIGNED_FORMAT} */ public record SignedDelta( - long magicNumber, ByteString superblock, List<SignedDelta.Signature> signatures) { - - /** A cryptographic signature. */ - public record Signature(String key, Variant data) { - private static final Decoder<Signature> DECODER = - Decoder.ofStructure( - Signature.class, Decoder.ofString(StandardCharsets.US_ASCII), Decoder.ofVariant()); - - public static Decoder<Signature> decoder() { - return DECODER; - } - } + long magicNumber, ByteString superblock, Map<String, Variant> signatures) { private static final Decoder<SignedDelta> DECODER = Decoder.ofStructure( SignedDelta.class, Decoder.ofLong().withByteOrder(ByteOrder.BIG_ENDIAN), ByteString.decoder(), - Decoder.ofArray(Signature.decoder())); + Decoder.ofDictionary(Decoder.ofString(StandardCharsets.US_ASCII), Decoder.ofVariant())); public static Decoder<SignedDelta> decoder() { return DECODER; diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SummarySignature.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SummarySignature.java index a05b96d..13bb432 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SummarySignature.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SummarySignature.java @@ -3,7 +3,7 @@ package eu.mulk.jgvariant.ostree; import eu.mulk.jgvariant.core.Decoder; import eu.mulk.jgvariant.core.Variant; import java.nio.charset.StandardCharsets; -import java.util.List; +import java.util.Map; /** * A collection of cryptographic signatures for a {@link Summary}. @@ -12,22 +12,11 @@ import java.util.List; * * <p>Reference: {@code ostree-repo-static-delta-private.h#OSTREE_SUMMARY_SIG_GVARIANT_STRING} */ -public record SummarySignature(List<Signature> signatures) { - - /** A cryptographic signature. */ - public record Signature(String key, Variant data) { - - private static final Decoder<Signature> DECODER = - Decoder.ofStructure( - Signature.class, Decoder.ofString(StandardCharsets.UTF_8), Decoder.ofVariant()); - - public static Decoder<Signature> decoder() { - return DECODER; - } - } +public record SummarySignature(Map<String, Variant> signatures) { private static final Decoder<SummarySignature> DECODER = - Decoder.ofArray(Signature.decoder()).map(SummarySignature::new); + Decoder.ofDictionary(Decoder.ofString(StandardCharsets.UTF_8), Decoder.ofVariant()) + .map(SummarySignature::new); public static Decoder<SummarySignature> decoder() { return DECODER; |