diff --git a/docs/modules/release-notes/pages/0.30.adoc b/docs/modules/release-notes/pages/0.30.adoc index ff95c39c..ff6d6ff6 100644 --- a/docs/modules/release-notes/pages/0.30.adoc +++ b/docs/modules/release-notes/pages/0.30.adoc @@ -99,7 +99,7 @@ To ensure compatibility, use the `--grammar-version 1` CLI flag. === `pkl-binary` in-language Renderer A new in-language API has been added to render values into xref:bindings-specification:binary-encoding.adoc[pkl-binary encoding] (https://github.com/apple/pkl/pull/1203[#1203], -https://github.com/apple/pkl/pull/1250[#1250]). +https://github.com/apple/pkl/pull/1250[#1250], https://github.com/apple/pkl/pull/1275[#1275]). It's sometimes useful to separate Pkl evaluation from data consumption when used as application or service configuration. This is possible with the `pkl-binary` format, which is a lossless encoding of Pkl data. @@ -149,7 +149,7 @@ Java:: [source,java] ---- var encodedData = fetchEncodedData(); // some byte[] or InputStream -var config = Config.from(encodedData); +var config = Config.fromPklBinary(encodedData); var appConfig = config.as(AppConfig.class); ---- @@ -158,7 +158,7 @@ Kotlin:: [source,kotlin] ---- val encodedData = fetchEncodedData() // some ByteArray or InputStream -val config = Config.from(encodedData, ValueMapper.preconfigured().forKotlin()) +val config = Config.fromPklBinary(encodedData, ValueMapper.preconfigured().forKotlin()) val appConfig = config.to() ---- @@ -168,7 +168,7 @@ Go:: ---- encodedData := fetchEncodedData() // some []byte var appConfig AppConfig -if err := pkl.Unmarshal(encodedData, &result); err != nil { +if err := pkl.Unmarshal(encodedData, &appConfig); err != nil { // handle error } ---- diff --git a/pkl-config-java/src/main/java/org/pkl/config/java/Config.java b/pkl-config-java/src/main/java/org/pkl/config/java/Config.java index 6c6d6df3..a8b7e612 100644 --- a/pkl-config-java/src/main/java/org/pkl/config/java/Config.java +++ b/pkl-config-java/src/main/java/org/pkl/config/java/Config.java @@ -78,7 +78,7 @@ public interface Config { * * @return the encoded config */ - static Config from(byte[] bytes, ValueMapper mapper) { + static Config fromPklBinary(byte[] bytes, ValueMapper mapper) { return makeConfig(PklBinaryDecoder.decode(bytes), mapper); } @@ -87,8 +87,8 @@ public interface Config { * * @return the encoded config */ - static Config from(byte[] bytes) { - return from(bytes, ValueMapper.preconfigured()); + static Config fromPklBinary(byte[] bytes) { + return fromPklBinary(bytes, ValueMapper.preconfigured()); } /** @@ -97,7 +97,7 @@ public interface Config { * * @return the encoded config */ - static Config from(InputStream inputStream, ValueMapper mapper) { + static Config fromPklBinary(InputStream inputStream, ValueMapper mapper) { return makeConfig(PklBinaryDecoder.decode(inputStream), mapper); } @@ -106,8 +106,8 @@ public interface Config { * * @return the encoded config */ - static Config from(InputStream inputStream) { - return from(inputStream, ValueMapper.preconfigured()); + static Config fromPklBinary(InputStream inputStream) { + return fromPklBinary(inputStream, ValueMapper.preconfigured()); } private static Config makeConfig(Object decoded, ValueMapper mapper) { diff --git a/pkl-config-java/src/test/java/org/pkl/config/java/ConfigPklBinaryDecoderTest.java b/pkl-config-java/src/test/java/org/pkl/config/java/ConfigPklBinaryDecoderTest.java index 71c56fec..26591429 100644 --- a/pkl-config-java/src/test/java/org/pkl/config/java/ConfigPklBinaryDecoderTest.java +++ b/pkl-config-java/src/test/java/org/pkl/config/java/ConfigPklBinaryDecoderTest.java @@ -23,7 +23,7 @@ public class ConfigPklBinaryDecoderTest extends AbstractConfigTest { @Override protected Config getPigeonConfig() { // pigeon { age = 30; friends = List("john", "mary"); address { street = "Fuzzy St." } } - return Config.from( + return Config.fromPklBinary( Base64.getDecoder() .decode( "lAGkdGVzdNklZmlsZTovLy9Vc2Vycy9qYmFzY2gvc3JjL3BrbC90ZXN0LnBrbJGTEKZwaWdlb26UAadEeW5hbWljqHBrbDpiYXNlk5MQo2FnZR6TEKdmcmllbmRzkgSSpGpvaG6kbWFyeZMQp2FkZHJlc3OUAadEeW5hbWljqHBrbDpiYXNlkZMQpnN0cmVldKlGdXp6eSBTdC4=")); @@ -32,7 +32,7 @@ public class ConfigPklBinaryDecoderTest extends AbstractConfigTest { @Override protected Config getPigeonModuleConfig() { // age = 30; friends = List("john", "mary"); address { street = "Fuzzy St." } - return Config.from( + return Config.fromPklBinary( Base64.getDecoder() .decode( "lAGlc3RkaW6xZmlsZTovLy9kZXYvc3RkaW6TkxCjYWdlHpMQp2ZyaWVuZHOSBJKkam9obqRtYXJ5kxCnYWRkcmVzc5QBp0R5bmFtaWOocGtsOmJhc2WRkxCmc3RyZWV0qUZ1enp5IFN0Lg==")); @@ -41,7 +41,7 @@ public class ConfigPklBinaryDecoderTest extends AbstractConfigTest { @Override protected Config getPairConfig() { // x { first = "file/path"; second = 42 } - return Config.from( + return Config.fromPklBinary( Base64.getDecoder() .decode( "lAGlc3RkaW6xZmlsZTovLy9kZXYvc3RkaW6RkxCheJQBp0R5bmFtaWOocGtsOmJhc2WSkxClZmlyc3SpZmlsZS9wYXRokxCmc2Vjb25kKg==")); @@ -50,7 +50,7 @@ public class ConfigPklBinaryDecoderTest extends AbstractConfigTest { @Override protected Config getMapConfig() { // x = Map("one", 1, "two", 2) - return Config.from( + return Config.fromPklBinary( Base64.getDecoder().decode("lAGlc3RkaW6xZmlsZTovLy9kZXYvc3RkaW6RkxCheJICgqNvbmUBo3R3bwI=")); } }