@Override
    public byte[] encodeWithEnvelope(ClusterStateBundle stateBundle) {
        EncodedClusterStateBundle toEnvelope = encode(stateBundle);

        Slime slime = new Slime();
        Cursor root = slime.setObject();
        root.setLong("compression-type", toEnvelope.getCompression().type().getCode());
        root.setLong("uncompressed-size", toEnvelope.getCompression().uncompressedSize());
        root.setData("data", toEnvelope.getCompression().data());
        return BinaryFormat.encode(slime);
    }
Implementation of ClusterStateBundleCodec which uses structured Slime binary encoding
to implement (de-)serialization of ClusterStateBundle instances. Encoding format is
intentionally extensible so that we may add other information to it later.

LZ4 compression is transparently applied during encoding and decompression is
subsequently applied during decoding.

Implements optional Slime-based enveloping for *WithEnvelope methods, which removes
need to explicitly track compression metadata by the caller.
clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodec.java