From 73202882a20e2801837a16ac25e25d5d36efbeb1 Mon Sep 17 00:00:00 2001 From: Ashley Williams Date: Thu, 6 Apr 2023 10:08:40 -0500 Subject: [PATCH] release: 0.1.0 --- CHANGELOG.md | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4b36bb..1ff1daf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,100 @@ # Changelog +## v0.1.0 - 2023-04-06 + +### ๐ŸŽ Features + +- **โœจ New type: `SourceFile` - [Gankra], [pr25]** + + `SourceFile` is a new asset type which is a readonly String version of + `Asset` wrapped in an `Arc`. The purpose of this type is to be cheap to + clone and pass around everywhere so that errors can refer to it (using the + miette `#[source_code]` and `#[label]` attributes). The `Arc` ensures this + is cheap at minimal overhead. The String ensures the contents make sense to + display. + +- **โœจ New type: `Spanned` - [Gankra], [pr25]** + + `Spanned` is a new type which tries to behave like `Box` in the sense + that it's "as if" it's a `T` but with source span info embedded. If you want + to remember that a value was decoded from an asset at bytes 100 to 200, you + can wrap it in a `Spanned` without disrupting any of the code that uses it. + Then if you determine that value caused a problem, you can call + `Spanned::span(&value)` to extract the span and have miette include the + asset context in the error message. + +- **โœจ New features: `serde_json` and `toml-rs` - [Gankra], [pr25]** + + `json-serde` and `toml-serde` are new features which pull in dedicated + support for `serde_json` and `toml-rs`. These features add `deserialize_json` + and `deserialize_toml` methods to `SourceFile` which understand those crates' + native error types and produce full pretty miette-y errors when deserializing, + like this: + + ``` + ร— failed to read JSON + โ•ฐโ”€โ–ถ trailing comma at line 3 column 1 + โ•ญโ”€[src/tests/res/bad-package.json:2:1] + 2 โ”‚ "name": null, + 3 โ”‚ } + ยท โ”€ + โ•ฐโ”€โ”€โ”€โ”€ + ``` + + (In this case serde_json itself points at the close brace and not the actual comma, we're just faithfully forwarding that.) + + `Spanned` has special integration with `toml-rs`, because it's actually a + fork of that crate's [own magic `Spanned` type]. If you deserialize a struct + that contains a `Spanned` it will automagically fill in the span info + for you. Ours further improves on this by putting in more effort to be totally + transparent like `Box`. + +- **โœจ New function: `write_new` for `LocalAsset` - [ashleygwilliams], [pr28]** + + axoasset was first conceived to handle assets declared by end users for use + in `oranda`, but quickly grew to encompass all fs/network calls. one of the + things we often need to do is create a new file. This is only available on + `LocalAsset` as, at least for the moment, that is the only place axoasset + has permissions to create new assets. + +- **make `RemoteAsset` an optional feature - [Gankra], [pr26]** + + A feature of `axoasset` is that it is agnostic to the origin of the asset: + it can be local or remote. However, often, authors can be certain that they + will only be using local assets. In this case, it reduces dependencies to + not include the remote functionality. Previously this wasn't possible! + +- **`miette-ify` errors - [Gankra], [pr24]** + + Previously we were using `thiserror` for error handling, but to be consistent + across our toolchain, we've updated our errors to use `miette`. This has the + added benefit of formalizing structures we were informally building into our + error types (help/diagnostic text, forwarding the bare error as details, etc). + + +- **consistent `Asset` interface - [ashleygwilliams], [pr30]** + + With 3 asset types, `LocalAsset`, `RemoteAsset`, and `SourceFile`, it felt + important to align their structures so they could be used nearly identically. + Every type now has a: + + - `origin_path`: the original source of the file + - `filename`: derived from the `origin_path` and, in the case of `RemoteAsset`s + also the headers from the network response. + - `contents`: the contents of the asset as bytes or a String depending on + asset type + +[ashleygwilliams]: https://github.com/ashleygwilliams +[gankra]: https://github.com/gankra + +[pr24]: https://github.com/axodotdev/axoasset/pull/24 +[pr25]: https://github.com/axodotdev/axoasset/pull/25 +[pr26]: https://github.com/axodotdev/axoasset/pull/26 +[pr28]: https://github.com/axodotdev/axoasset/pull/28 +[pr30]: https://github.com/axodotdev/axoasset/pull/30 + +[own magic `Spanned` type]: https://docs.rs/toml/latest/toml/struct.Spanned.html + ## v0.0.1 - 2023-02-14 Initial release. diff --git a/Cargo.toml b/Cargo.toml index 4c9cc9c..b78eb4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "axoasset" description = ">o_o<" -version = "0.0.1" +version = "0.1.0" edition = "2021" license = "MIT OR Apache-2.0"